-
Notifications
You must be signed in to change notification settings - Fork 1
サーバーアクションに変更&ドキュメントをAIに読ませる #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploying with
|
| 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 |
app/actions/chatActions.ts
Outdated
|
|
||
| const genAI = new GoogleGenerativeAI(process.env.API_KEY!); | ||
|
|
||
| export async function askAI(params: unknown): Promise<FormState> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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でもなんでもいいけど)
|
(Next.jsのドキュメントを読み直したらServerActionというのはformのactionに渡す場合だけで、自分で呼び出すものはServerFunctionというっぽい。どうでもいいけど) |
Uh oh!
There was an error while loading. Please reload this page.