Skip to content

Commit

Permalink
Updated query endpoint: query as body parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninoLorenzo committed Jul 1, 2024
1 parent f38e6a7 commit 3ef75b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ai-ops-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def chat(self, print_name=True):
if q == '-1':
break

with self.client.get(
with self.client.post(
query_url,
params={'q': q},
json={'query': q},
headers=None,
stream=True) as resp:
print('assistant: ')
Expand Down
11 changes: 6 additions & 5 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import os

from dotenv import load_dotenv
from fastapi import FastAPI
from fastapi import FastAPI, HTTPException, Body
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import StreamingResponse
from pydantic_settings import BaseSettings
Expand Down Expand Up @@ -166,14 +166,15 @@ def query_generator(sid: int, q: str):
yield chunk


# TODO: query should be body parameter
@app.get('/session/{sid}/query/')
def query(sid: int, q: str):
@app.post('/session/{sid}/query/')
def query(sid: int, body: dict = Body(...)):
"""
Makes a query to the Agent.
Returns the stream for the response.
"""
# TODO: query should go in body
q = body.get("query")
if not q:
raise HTTPException(status_code=400, detail="Query parameter is required")
return StreamingResponse(query_generator(sid, q))


Expand Down

0 comments on commit 3ef75b7

Please sign in to comment.