Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
papayalabs committed Nov 26, 2024
1 parent fc2e349 commit 62758f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/services/ai_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def get_oneoff_message(instructions, messages, params = {})
response = @client.send(client_method_name, ** @client_config)

response.dig("content", 0, "text") ||
response.dig("choices", 0, "message", "content") ||
response.dig("candidates",0,"content","parts",0,"text")
response.dig("choices", 0, "message", "content")
end

def stream_next_conversation_message(&chunk_handler)
Expand Down
2 changes: 1 addition & 1 deletion app/services/ai_backend/gemini.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def set_client_config(config)
end

def get_oneoff_message(instructions, messages, params = {})
response = @client.generate_content( { system_instruction: { role: "user", parts: { text: instructions }}, contents: { role: "user", parts: { text: messages.first }}})
response = @client.generate_content( { system_instruction: system_message(instructions), contents: { role: "user", parts: { text: messages.first }}})
response.dig("candidates",0,"content","parts",0,"text")
end

Expand Down

0 comments on commit 62758f0

Please sign in to comment.