Skip to content

Commit

Permalink
Merge pull request #7 from JuliaConstraints/llm_fix
Browse files Browse the repository at this point in the history
Fix API URLs
  • Loading branch information
nicoladicicco authored Sep 24, 2024
2 parents c893385 + dad518f commit 67ebec6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/llm.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const GROQ_URL::String = "https://api.groq.com/openai/v1/chat/completions"
const GEMINI_URL::String = "https://generativelanguage.googleapis.com/v1beta/models/{{model_id}}:generateContent"
const GEMINI_URL_STREAM::String = "https://generativelanguage.googleapis.com/v1beta/models/{{model_id}}:streamGenerateContent?alt=sse"
const GEMINI_URL::String = "https://generativelanguage.googleapis.com/v1beta/models/{{model_id}}"

abstract type AbstractLLM end
abstract type OpenAILLM <: AbstractLLM end
Expand Down Expand Up @@ -93,7 +92,8 @@ end
Returns a completion for the given prompt using the Google Gemini LLM API.
"""
function get_completion(llm::GoogleLLM, prompt::Prompt)
url = replace(GEMINI_URL, "{{model_id}}" => llm.model_id)
url = replace(llm.url, "{{model_id}}" => llm.model_id)
url *= ":generateContent"
headers = [
"x-goog-api-key" => "$(llm.api_key)",
"Content-Type" => "application/json",
Expand Down Expand Up @@ -170,7 +170,8 @@ Returns a completion for the given prompt using the Google Gemini LLM API.
The completion is streamed to the terminal as it is generated.
"""
function stream_completion(llm::GoogleLLM, prompt::Prompt)
url = replace(GEMINI_URL_STREAM, "{{model_id}}" => llm.model_id)
url = replace(llm.url, "{{model_id}}" => llm.model_id)
url *= ":streamGenerateContent?alt=sse"
headers = [
"x-goog-api-key" => "$(llm.api_key)",
"Content-Type" => "application/json",
Expand Down

0 comments on commit 67ebec6

Please sign in to comment.