Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/chat_session_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestChatSessionService(t *testing.T) {
}

// Check that updated chat session matches expected values
// TODO: timezone time || !retrievedSession.UpdatedAt.Equal(updated_params.UpdatedAt)
// UpdatedAt is generated by the database; verify updated fields instead of strict timestamp equality.
if retrievedSession.Topic != updated_params.Topic {
t.Errorf("chat session mismatch: expected Topic=%s, got Topic=%s ",
updated_params.Topic, retrievedSession.Topic)
Expand Down
8 changes: 5 additions & 3 deletions api/model_gemini_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ func (m *GeminiChatModel) Stream(w http.ResponseWriter, chatSession sqlc_queries

llmAnswer, err := gemini.HandleRegularResponse(*m.client.client, req)
if err != nil {
return nil, ErrInternalUnexpected.WithMessage("Failed to generate regular resposne").WithDebugInfo(err.Error())
return nil, ErrInternalUnexpected.WithMessage("Failed to generate regular response").WithDebugInfo(err.Error())
}
if llmAnswer != nil {
llmAnswer.AnswerId = answerID
if llmAnswer == nil {
return nil, ErrInternalUnexpected.WithMessage("Empty response from Gemini")
}

llmAnswer.AnswerId = answerID
response := constructChatCompletionStreamResponse(answerID, llmAnswer.Answer)
data, _ := json.Marshal(response)
fmt.Fprint(w, string(data))
Expand Down
6 changes: 5 additions & 1 deletion api/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ func Test_firstN(t *testing.T) {
}{
{"01", args{"hello", 2}, "he"},
{"02", args{"hello", 5}, "hello"},
{"02", args{"hello", 50}, "hello"},
{"03", args{"hello", 50}, "hello"},
{"04", args{"你好世界", 2}, "你好"},
{"05", args{"", 3}, ""},
{"06", args{"hello", 0}, ""},
{"07", args{"🙂🙃", 1}, "🙂"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
16 changes: 4 additions & 12 deletions docs/artifact_gallery_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,12 @@ The gallery integrates with the chat application's API:

```javascript
// Example: Getting artifacts from a specific session
const artifacts = await fetch(`/api/chat/sessions/${sessionId}/artifacts`);
const messages = await fetch(`/api/uuid/chat_messages/chat_sessions/${sessionId}`);
// Artifacts are included in each message payload as the `artifacts` field

// Example: Executing code artifact
const result = await fetch(`/api/artifacts/${artifactId}/execute`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
code: artifactContent,
language: 'javascript'
})
});
// Code execution is handled client-side in Artifact Editor/Sandbox components,
// not by a dedicated backend `/api/artifacts/:id/execute` endpoint.
```

## Future Enhancements
Expand Down
16 changes: 4 additions & 12 deletions docs/artifact_gallery_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,12 @@

```javascript
// 示例:从特定会话获取制品
const artifacts = await fetch(`/api/chat/sessions/${sessionId}/artifacts`);
const messages = await fetch(`/api/uuid/chat_messages/chat_sessions/${sessionId}`);
// 制品包含在每条消息的 `artifacts` 字段中

// 示例:执行代码制品
const result = await fetch(`/api/artifacts/${artifactId}/execute`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
code: artifactContent,
language: 'javascript'
})
});
// 代码执行由前端的 Artifact Editor/Sandbox 组件处理,
// 后端没有独立的 `/api/artifacts/:id/execute` 接口。
```

## 未来增强
Expand Down
Loading