Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API URLs #7

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
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
Loading