Skip to content

Commit

Permalink
Missed changes to jobs handler
Browse files Browse the repository at this point in the history
  • Loading branch information
danopato committed Mar 5, 2024
1 parent 9640c35 commit bd23321
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions gai-backend/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,20 @@ async def add_job(self, id, bid, job):
async def process_jobs(self):
while True:
priority, job_params = await self.queue.get()
print(f"process_jobs: got job: {job_params}")
id, bid, job = job_params
await self.sessions[id]['send'].put(json.dumps({'type': 'started'}))
result = ""
data = {'model': self.model, 'messages': [{'role': 'user', 'content': job['prompt']}]}
print(f'data: {data}')
print(f'llmparams: {self.llmparams}')
data = {**data, **self.llmparams}
headers = {"Content-Type":"application/json"}
print(f'llmkey: {self.llmkey}')
headers = {"Content-Type": "application/json"}
if not self.llmkey is None:
headers["Authorization"] = f"Bearer {self.llmkey}"
r = requests.post(self.url, data=json.dumps(data), headers=headers)
result = r.json()
print(result)
if result['object'] != 'chat.completion':
print('*** Error from llm')
print('*** process_jobs: Error from llm')
print(f"from job: {job_params}")
print(result)
continue
response = result['choices'][0]['message']['content']
model = result['model']
Expand Down

0 comments on commit bd23321

Please sign in to comment.