Skip to content

Conversation

@hiromeee
Copy link
Contributor

@hiromeee hiromeee commented Aug 15, 2025

  • fetchからサーバーアクションに変更
  • AIにセクションごとに分けたドキュメントを与えるようにした
    • 現状、ただAIに投げてるだけなのでプロンプトを作成した方が良い

@hiromeee hiromeee requested a review from na-trium-144 August 15, 2025 11:26
@hiromeee hiromeee self-assigned this Aug 15, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 15, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
my-code 479306d Commit Preview URL

Branch Preview URL
Aug 17 2025, 12:33 PM

@hiromeee hiromeee changed the title fetchからサーバーアクションに変更 サーバーアクションに変更 Aug 15, 2025
@hiromeee hiromeee changed the title サーバーアクションに変更 サーバーアクションに変更&ドキュメントをAIに読ませる Aug 15, 2025
@hiromeee hiromeee requested a review from na-trium-144 August 16, 2025 15:05

const genAI = new GoogleGenerativeAI(process.env.API_KEY!);

export async function askAI(params: unknown): Promise<FormState> {
Copy link
Contributor

@na-trium-144 na-trium-144 Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export async function askAI(params: unknown): Promise<FormState> {
type ChatParams = z.input<typeof ChatSchema>;
export async function askAI(params: ChatParams): Promise<FormState> {

TypeScriptの型指定はコードを書く際の間違いをチェックするためのもの、validationは実際の値のチェックのためで、目的が異なり両方必要です
(引数の型はここでは呼び出し側のためのもの)

type ChatParams = z.input<typeof ChatSchema>;

と書くことで

interface ChatParams {
  userQuestion: string;
  documentContent: string;
}

と同じものがChatSchemaの定義から自動で作られます
(名前はChatSchemaでもChatParamsでもなんでもいいけど)

@na-trium-144
Copy link
Contributor

(Next.jsのドキュメントを読み直したらServerActionというのはformのactionに渡す場合だけで、自分で呼び出すものはServerFunctionというっぽい。どうでもいいけど)

@hiromeee hiromeee requested a review from na-trium-144 August 17, 2025 15:15
@hiromeee hiromeee merged commit ea6a9e5 into main Aug 18, 2025
3 checks passed
@hiromeee hiromeee deleted the action branch August 18, 2025 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants