Skip to content

Commit

Permalink
Update abstra-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
abstra-bot committed Sep 18, 2024
1 parent e137140 commit 29e78c1
Show file tree
Hide file tree
Showing 227 changed files with 420 additions and 417 deletions.
2 changes: 1 addition & 1 deletion abstra_internals/interface/sdk/ai/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def prompt(
function = _build_function_tool_call(format)
tools.append({"type": "function", "function": function})

response = ai_repository.prompt(messages, tools, temperature).json()
response = ai_repository.prompt(messages, tools, temperature)

if response.get("error"):
raise Exception(response["error"])
Expand Down
33 changes: 18 additions & 15 deletions abstra_internals/repositories/ai.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from abc import ABC, abstractmethod
from typing import Any, List

Expand All @@ -12,30 +13,29 @@ def __init__(self, base_url: str) -> None:
self.url = f"{base_url}/ai"

@abstractmethod
def prompt(
self, messages: List[Any], tools: List[Any], temperature: float
) -> requests.Response:
def prompt(self, messages: List[Any], tools: List[Any], temperature: float):
raise NotImplementedError()


class ProductionAiApiHttpClient(AiApiHttpClient):
def prompt(
self, messages: List[Any], tools: List[Any], temperature: float
) -> requests.Response:
def prompt(self, messages: List[Any], tools: List[Any], temperature: float):
body = {
"messages": messages,
"tools": tools,
"temperature": temperature,
}
r = requests.post(f"{self.url}/prompt", headers=SIDECAR_HEADERS, json=body)
r.raise_for_status()
return r
response = requests.post(
f"{self.url}/prompt", headers=SIDECAR_HEADERS, json=body
)
try:
response = response.json()
return response
except json.JSONDecodeError:
raise Exception(f"Error parsing JSON: {response.text}")


class LocalAiApiHttpClient(AiApiHttpClient):
def prompt(
self, messages: List[Any], tools: List[Any], temperature: float
) -> requests.Response:
def prompt(self, messages: List[Any], tools: List[Any], temperature: float):
body = {
"messages": messages,
"tools": tools,
Expand All @@ -44,9 +44,12 @@ def prompt(
headers = resolve_headers()
if headers is None:
raise Exception("You must be logged in to use AI")
r = requests.post(f"{self.url}/prompt", headers=headers, json=body)
r.raise_for_status()
return r
response = requests.post(f"{self.url}/prompt", headers=headers, json=body)
try:
response = response.json()
return response
except json.JSONDecodeError:
raise Exception(f"Error parsing JSON: {response.text}")


def ai_api_http_client_factory() -> AiApiHttpClient:
Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions abstra_statics/dist/assets/ApiKeys.0336a221.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions abstra_statics/dist/assets/ApiKeys.cfef5eba.js

This file was deleted.

2 changes: 0 additions & 2 deletions abstra_statics/dist/assets/App.6b5e0637.js

This file was deleted.

2 changes: 2 additions & 0 deletions abstra_statics/dist/assets/App.8347012d.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

2 changes: 2 additions & 0 deletions abstra_statics/dist/assets/Avatar.0aead593.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 29e78c1

Please sign in to comment.