Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,15 +73,27 @@ class MyClient(discord.Client):
|
|
| 73 |
loop = asyncio.get_event_loop()
|
| 74 |
response = await loop.run_in_executor(None, lambda: self.math_pipe([{"role": "user", "content": question}]))
|
| 75 |
math_response = response[0]['generated_text']
|
| 76 |
-
|
| 77 |
# QuickLaTeX API๋ฅผ ์ด์ฉํ์ฌ LaTeX ์์์ ์ด๋ฏธ์ง๋ก ๋ณํ
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
return math_response, image_url
|
| 84 |
-
|
| 85 |
async def generate_response(self, message):
|
| 86 |
global conversation_history
|
| 87 |
user_input = message.content
|
|
|
|
| 73 |
loop = asyncio.get_event_loop()
|
| 74 |
response = await loop.run_in_executor(None, lambda: self.math_pipe([{"role": "user", "content": question}]))
|
| 75 |
math_response = response[0]['generated_text']
|
| 76 |
+
|
| 77 |
# QuickLaTeX API๋ฅผ ์ด์ฉํ์ฌ LaTeX ์์์ ์ด๋ฏธ์ง๋ก ๋ณํ
|
| 78 |
+
data = {
|
| 79 |
+
'formula': math_response,
|
| 80 |
+
'fsize': '17px',
|
| 81 |
+
'fcolor': '000000',
|
| 82 |
+
'mode': '0',
|
| 83 |
+
'out': '1',
|
| 84 |
+
'remhost': 'quicklatex.com'
|
| 85 |
+
}
|
| 86 |
+
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
| 87 |
+
quicklatex_response = requests.post('https://quicklatex.com/latex3.f', data=data, headers=headers)
|
| 88 |
+
if quicklatex_response.status_code == 200:
|
| 89 |
+
# ์๋ต ํ
์คํธ์์ ์ฒซ ๋ฒ์งธ ์ค์ ๊ฐ์ ธ์ URL์ ์ถ์ถ
|
| 90 |
+
image_url = quicklatex_response.text.splitlines()[1]
|
| 91 |
+
else:
|
| 92 |
+
image_url = "Error generating image"
|
| 93 |
+
logging.error(f"QuickLaTeX error: {quicklatex_response.text}")
|
| 94 |
|
| 95 |
return math_response, image_url
|
| 96 |
+
|
| 97 |
async def generate_response(self, message):
|
| 98 |
global conversation_history
|
| 99 |
user_input = message.content
|