mirror of
https://github.com/ollama/ollama.git
synced 2026-04-26 18:55:53 +02:00
prototype
This commit is contained in:
@@ -293,11 +293,13 @@ func (s *Server) GenerateHandler(c *gin.Context) {
|
||||
var sb strings.Builder
|
||||
defer close(ch)
|
||||
if err := r.Completion(c.Request.Context(), llm.CompletionRequest{
|
||||
Prompt: prompt,
|
||||
Images: images,
|
||||
Format: req.Format,
|
||||
Options: opts,
|
||||
Prompt: prompt,
|
||||
Images: images,
|
||||
Format: req.Format,
|
||||
LogProbs: req.LogProbs,
|
||||
Options: opts,
|
||||
}, func(cr llm.CompletionResponse) {
|
||||
fmt.Printf("banana: %#v\n", cr)
|
||||
res := api.GenerateResponse{
|
||||
Model: req.Model,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
@@ -311,6 +313,13 @@ func (s *Server) GenerateHandler(c *gin.Context) {
|
||||
EvalDuration: cr.EvalDuration,
|
||||
},
|
||||
}
|
||||
for _, p := range cr.LogProbs {
|
||||
res.LogProbs = append(res.LogProbs, api.TokenProbs{
|
||||
TokenID: p.TokenID,
|
||||
LogProb: p.LogProb,
|
||||
Token: p.Token,
|
||||
})
|
||||
}
|
||||
|
||||
if _, err := sb.WriteString(cr.Content); err != nil {
|
||||
ch <- gin.H{"error": err.Error()}
|
||||
@@ -1466,10 +1475,11 @@ func (s *Server) ChatHandler(c *gin.Context) {
|
||||
var sb strings.Builder
|
||||
var toolCallIndex int = 0
|
||||
if err := r.Completion(c.Request.Context(), llm.CompletionRequest{
|
||||
Prompt: prompt,
|
||||
Images: images,
|
||||
Format: req.Format,
|
||||
Options: opts,
|
||||
Prompt: prompt,
|
||||
Images: images,
|
||||
Format: req.Format,
|
||||
LogProbs: req.LogProbs,
|
||||
Options: opts,
|
||||
}, func(r llm.CompletionResponse) {
|
||||
res := api.ChatResponse{
|
||||
Model: req.Model,
|
||||
@@ -1484,6 +1494,13 @@ func (s *Server) ChatHandler(c *gin.Context) {
|
||||
EvalDuration: r.EvalDuration,
|
||||
},
|
||||
}
|
||||
for _, p := range r.LogProbs {
|
||||
res.LogProbs = append(res.LogProbs, api.TokenProbs{
|
||||
TokenID: p.TokenID,
|
||||
LogProb: p.LogProb,
|
||||
Token: p.Token,
|
||||
})
|
||||
}
|
||||
|
||||
if r.Done {
|
||||
res.TotalDuration = time.Since(checkpointStart)
|
||||
|
||||
Reference in New Issue
Block a user