krammnic commited on
Commit
a2db262
·
verified ·
1 Parent(s): 835e0af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -5,6 +5,12 @@ import asyncio
5
 
6
  from groq import Groq, AsyncGroq
7
 
 
 
 
 
 
 
8
  client = AsyncGroq(
9
  api_key="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",
10
  )
@@ -15,6 +21,40 @@ SYSTEM_PROMPT = """
15
 
16
  app = FastAPI()
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  @app.post("/get_response")
20
  async def read_root(messages: list[dict]):
 
5
 
6
  from groq import Groq, AsyncGroq
7
 
8
+ from fastapi import FastAPI, File, UploadFile
9
+ from fastapi.responses import HTMLResponse
10
+ import shutil
11
+ import os
12
+
13
+
14
  client = AsyncGroq(
15
  api_key="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",
16
  )
 
21
 
22
  app = FastAPI()
23
 
24
+ import google.generativeai as genai
25
+ import os
26
+
27
+ genai.configure(api_key="AIzaSyBGhEOy-JYMzGtTcRjBjP51OGR168WKRFw")
28
+
29
+
30
+ client = AsyncGroq(
31
+ api_key="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",
32
+ )
33
+ messages=messages,
34
+ model="llama3-70b-8192",
35
+ )
36
+ return chat_completion.choices[0].message.content
37
+
38
+
39
+ @app.post("/upload-image/")
40
+ async def upload_image(file: UploadFile = File(...)):
41
+ os.makedirs("uploads", exist_ok=True)
42
+
43
+
44
+ file_location = f"uploads/{file.filename}"
45
+ with open(file_location, "wb") as buffer:
46
+ shutil.copyfileobj(file.file, buffer)
47
+
48
+ myfile = genai.upload_file(file_location)
49
+
50
+ model = genai.GenerativeModel("gemini-1.5-flash")
51
+ result = model.generate_content(
52
+ [myfile, "\n\n", "Проверь работу на фото, дай координаты всех слов в формате OpenCV, где допущина ошибка, также дай координаты мест где нужна была запятая(квадратом)."]
53
+ )
54
+
55
+ return result.text
56
+
57
+
58
 
59
  @app.post("/get_response")
60
  async def read_root(messages: list[dict]):