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> { |
Contributor
There was a problem hiding this comment.
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でもなんでもいいけど)
Contributor
|
(Next.jsのドキュメントを読み直したらServerActionというのはformのactionに渡す場合だけで、自分で呼び出すものはServerFunctionというっぽい。どうでもいいけど) |
na-trium-144
approved these changes
Aug 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.