Skip to content

Commit 3ad546d

Browse files
committed
Resolve merge conflicts
1 parent 4c97248 commit 3ad546d

File tree

3 files changed

+91
-5
lines changed

3 files changed

+91
-5
lines changed

internal/services/toolkit/client/get_conversation_title_v2.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ func (a *AIClientV2) GetConversationTitleV2(ctx context.Context, inappChatHistor
2929
message := strings.Join(messages, "\n")
3030
message = fmt.Sprintf("%s\nBased on above conversation, generate a short, clear, and descriptive title that summarizes the main topic or purpose of the discussion. The title should be concise, specific, and use natural language. Avoid vague or generic titles. Use abbreviation and short words if possible. Use 3-5 words if possible. Give me the title only, no other text including any other words.", message)
3131

32-
_, resp, err := a.ChatCompletionV2(ctx, "gpt-5-nano", OpenAIChatHistory{
32+
// Default model if user is not using their own
33+
modelToUse := "gpt-5-nano"
34+
if llmProvider.IsCustomModel {
35+
modelToUse = modelSlug
36+
}
37+
38+
_, resp, err := a.ChatCompletionV2(ctx, modelToUse, OpenAIChatHistory{
3339
openai.SystemMessage("You are a helpful assistant that generates a title for a conversation."),
3440
openai.UserMessage(message),
3541
}, llmProvider)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package xtramcp
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"encoding/json"
7+
"fmt"
8+
"net/http"
9+
"strings"
10+
)
11+
12+
// PaperAbstractResponse represents the response from XtraMCP paper-abstract REST API
13+
type PaperAbstractResponse struct {
14+
Success bool `json:"success"`
15+
Found bool `json:"found"`
16+
Title string `json:"title"`
17+
Abstract string `json:"abstract"`
18+
}
19+
20+
// PaperAbstractsRequest represents the request body for batch paper abstracts API
21+
type PaperAbstractsRequest struct {
22+
Titles []string `json:"titles"`
23+
}
24+
25+
// PaperAbstractsResponse represents the response from batch paper abstracts API
26+
type PaperAbstractsResponse struct {
27+
Success bool `json:"success"`
28+
Results []PaperAbstractResponse `json:"results"`
29+
}
30+
31+
// XtraMCPServices provides access to XtraMCP REST APIs that don't require MCP session
32+
type XtraMCPServices struct {
33+
baseURL string
34+
client *http.Client
35+
}
36+
37+
// NewXtraMCPServices creates a new XtraMCP services client
38+
func NewXtraMCPServices(baseURL string) *XtraMCPServices {
39+
return &XtraMCPServices{
40+
baseURL: baseURL,
41+
client: &http.Client{},
42+
}
43+
}
44+
45+
// GetPaperAbstracts fetches abstracts for multiple papers in a single request
46+
func (s *XtraMCPServices) GetPaperAbstracts(ctx context.Context, titles []string) (*PaperAbstractsResponse, error) {
47+
if len(titles) == 0 {
48+
return &PaperAbstractsResponse{Success: true, Results: []PaperAbstractResponse{}}, nil
49+
}
50+
51+
baseURL := strings.TrimSuffix(s.baseURL, "/mcp")
52+
endpoint := fmt.Sprintf("%s/api/paper-abstracts", baseURL)
53+
54+
reqBody, err := json.Marshal(PaperAbstractsRequest{Titles: titles})
55+
if err != nil {
56+
return nil, fmt.Errorf("failed to marshal request: %w", err)
57+
}
58+
59+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(reqBody))
60+
if err != nil {
61+
return nil, fmt.Errorf("failed to create request: %w", err)
62+
}
63+
req.Header.Set("Content-Type", "application/json")
64+
65+
resp, err := s.client.Do(req)
66+
if err != nil {
67+
return nil, fmt.Errorf("failed to make request: %w", err)
68+
}
69+
defer resp.Body.Close()
70+
71+
if resp.StatusCode != http.StatusOK {
72+
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
73+
}
74+
75+
var result PaperAbstractsResponse
76+
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
77+
return nil, fmt.Errorf("failed to decode response: %w", err)
78+
}
79+
80+
return &result, nil
81+
}

pkg/gen/api/chat/v2/chat.pb.go

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)