From 95c1bc75746f44e63b1337508600aa2bdfb21c38 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Thu, 15 Aug 2024 08:41:27 -0400 Subject: [PATCH] added gitnore --- .gitignore | 1 + WrenchBoard/src/requirements.txt | 3 ++- WrenchBoard/src/wrench.py | 35 +++++++++++++++++++++++++++++--- docker-compose.yml | 1 + 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/WrenchBoard/src/requirements.txt b/WrenchBoard/src/requirements.txt index d1f80a3..2b34c81 100644 --- a/WrenchBoard/src/requirements.txt +++ b/WrenchBoard/src/requirements.txt @@ -1,2 +1,3 @@ uvicorn -fastapi \ No newline at end of file +fastapi +openai \ No newline at end of file diff --git a/WrenchBoard/src/wrench.py b/WrenchBoard/src/wrench.py index 2ed5041..f36df2c 100644 --- a/WrenchBoard/src/wrench.py +++ b/WrenchBoard/src/wrench.py @@ -1,12 +1,41 @@ import uvicorn -from fastapi import FastAPI +from fastapi import FastAPI, HTTPException +from openai import OpenAI +from pydantic import BaseModel - app = FastAPI() +class Item(BaseModel): + ask: str + + @app.get("/") def central_function(): - return {"Neural":"Nine"} + client = OpenAI() + stream = client.chat.completions.create( + model="gpt-4o", + messages=[ + {"role": "user", "content": "create 10 science questions with answers"} + ] + ) + return {"Neural":"Nine", "TOTAL": stream } + + + @app.get("/askai") + def central_function(item: Item): + #print(item.ask) + client = OpenAI() + stream = client.chat.completions.create( + model="gpt-4o", + messages=[ + {"role": "user", "content": "create 10 science questions with answers"} + ] + ) + return {"Neural":"Nine", "TOTAL": stream } + + + +# return {"Neural":"Nine", "Res2":chunk.choices[0].delta.content, "TOTAL": stream } if __name__ == "__main__": uvicorn.run(app, port=3035,host="0.0.0.0") \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index aa316e1..96738fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,5 +11,6 @@ services: - 3035:3035 environment: - PORT=3035 + - OPENAI_API_KEY=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 volumes: src: \ No newline at end of file