Skip to content

Commit

Permalink
Rudimentary support for deepseek-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
RobBlackwell committed Jan 28, 2025
1 parent 04d9aab commit d4b4620
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
30 changes: 29 additions & 1 deletion golem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Time-stamp: <2025-01-10 13:46:35 rblackwell>
# Time-stamp: <2025-01-27 20:47:50 rblackwell>

"""Golem
Expand Down Expand Up @@ -33,6 +33,7 @@
ensure_json_serializable,
parse_list,
add_system_message,
lookup_variable,
)

from ollama import ask_ollama
Expand Down Expand Up @@ -111,6 +112,33 @@ def ask(

if provider == "openai":
return ask_openai(
provider,
model,
url,
key,
messages,
temperature,
seed,
top_p,
max_tokens,
logprobs,
top_logprobs,
)

if provider == "deepseek":
if model is None:
# See https://api-docs.deepseek.com/quick_start/pricing
model = "deepseek-chat" # Default

if url is None:
url = lookup_variable("DEEPSEEK_ENDPOINT")

if key is None:
key = lookup_variable("DEEPSEEK_API_KEY")

# API is OpenAI compatible
return ask_openai(
provider,
model,
url,
key,
Expand Down
3 changes: 2 additions & 1 deletion openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


def ask_openai(
provider,
model,
url,
api_key,
Expand Down Expand Up @@ -65,7 +66,7 @@ def ask_openai(
request, response = http_request(url, headers, json_data)
response = response.json()
answer = response["choices"][0]["message"]["content"]
provider = "openai"
provider = provider
model = response["model"]
except Exception as e:
fatal(f"EXCEPTION: {e} REQUEST: {request} RESPONSE: {response}")
Expand Down

0 comments on commit d4b4620

Please sign in to comment.