krammnic commited on
Commit
c58e3fa
·
verified ·
1 Parent(s): 552e624

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
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
  )
@@ -27,7 +33,26 @@ async def read_root(messages: list[dict]):
27
  messages=messages,
28
  model="llama3-70b-8192",
29
  )
30
- return chat_completion.choices[0].message.content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
 
33
 
 
5
 
6
  from groq import Groq, AsyncGroq
7
 
8
+ import google.generativeai as genai
9
+ import os
10
+
11
+ genai.configure(api_key="AIzaSyBGhEOy-JYMzGtTcRjBjP51OGR168WKRFw")
12
+
13
+
14
  client = AsyncGroq(
15
  api_key="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",
16
  )
 
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 {"filename": file.filename, "location": file_location}
56
 
57
 
58