Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -56,7 +56,6 @@ def generate_gpt4o_mini_response(context: str, query: str) -> str:
|
|
56 |
response = client.chat.completions.create(
|
57 |
model="gpt-4o-mini", # You can also use "gpt-4" if you have access
|
58 |
messages=messages,
|
59 |
-
max_tokens=150,
|
60 |
temperature=0.7
|
61 |
)
|
62 |
return response.choices[0].message.content.strip()
|
@@ -172,20 +171,19 @@ async def root():
|
|
172 |
with open("index.html") as f:
|
173 |
return f.read()
|
174 |
|
|
|
|
|
|
|
|
|
|
|
175 |
@app.get("/embed-code")
|
176 |
async def generate_embed_code(botid: str):
|
177 |
"""
|
178 |
Generates and returns a dynamic embed code snippet for the provided botid.
|
179 |
"""
|
180 |
embed_snippet = f"""
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
var script = document.createElement('script');
|
186 |
-
script.src = 'https://huggingface.co/path-to-your-hosted-js-file.js?botid=' + botid;
|
187 |
-
document.head.appendChild(script);
|
188 |
-
}})();
|
189 |
-
</script>
|
190 |
-
"""
|
191 |
return {"embed_code": embed_snippet}
|
|
|
56 |
response = client.chat.completions.create(
|
57 |
model="gpt-4o-mini", # You can also use "gpt-4" if you have access
|
58 |
messages=messages,
|
|
|
59 |
temperature=0.7
|
60 |
)
|
61 |
return response.choices[0].message.content.strip()
|
|
|
171 |
with open("index.html") as f:
|
172 |
return f.read()
|
173 |
|
174 |
+
@app.get("/bot.html", response_class=HTMLResponse)
|
175 |
+
async def bot_page():
|
176 |
+
with open("bot.html") as f:
|
177 |
+
return f.read()
|
178 |
+
|
179 |
@app.get("/embed-code")
|
180 |
async def generate_embed_code(botid: str):
|
181 |
"""
|
182 |
Generates and returns a dynamic embed code snippet for the provided botid.
|
183 |
"""
|
184 |
embed_snippet = f"""
|
185 |
+
<!-- SmartlyQ Chatbot Embed Code -->
|
186 |
+
<div id="smartlyq-chatbot-container"></div>
|
187 |
+
<script src="/static/chatbot.js?botid={botid}"></script>
|
188 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
return {"embed_code": embed_snippet}
|