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

Update text_client_utils.py #2729

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions inference/text-client/text_client_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DebugClient:
def __init__(self, backend_url, http_client=requests):
self.backend_url = backend_url
self.http_client = http_client
self.available_models = self.get_available_models()

def login(self, username):
auth_data = self.http_client.get(f"{self.backend_url}/auth/callback/debug", params={"code": username}).json()
Expand All @@ -28,7 +29,18 @@ def create_chat(self):
self.message_id = None
return self.chat_id

def get_available_models(self):
response = self.http_client.get(
f"{self.backend_url}/models",
headers=self.auth_headers,
)
response.raise_for_status()
return [model["name"] for model in response.json()]

def send_message(self, message, model_config_name):
available_models = self.get_available_models()
if model_config_name not in available_models:
raise ValueError(f"Invalid model config name: {model_config_name}")
response = self.http_client.post(
f"{self.backend_url}/chats/{self.chat_id}/prompter_message",
json={
Expand Down