Spaces:
Build error
Build error
Ruzgar ?????
commited on
Rename index.html to app.py
Browse files- app.py +38 -0
- index.html +0 -18
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# API bilgileri
|
| 5 |
+
API_URL = "https://beta.h10.pro/v1/chat/completions"
|
| 6 |
+
API_KEY = "sk-unlimited-magic"
|
| 7 |
+
|
| 8 |
+
# Streamlit arayüzü
|
| 9 |
+
st.title("Hugging Face API ile Chatbot")
|
| 10 |
+
st.write("Bu chatbot, Hugging Face üzerinde barındırılan bir API'yi kullanıyor.")
|
| 11 |
+
|
| 12 |
+
# Kullanıcıdan mesaj alma
|
| 13 |
+
user_input = st.text_input("Mesajınızı yazın:")
|
| 14 |
+
|
| 15 |
+
if st.button("Gönder"):
|
| 16 |
+
if user_input:
|
| 17 |
+
# API'ye istek gönderme
|
| 18 |
+
response = requests.post(
|
| 19 |
+
API_URL,
|
| 20 |
+
headers={"Authorization": f"Bearer {API_KEY}"},
|
| 21 |
+
json={
|
| 22 |
+
"model": "claude-3-haiku", # Veya kullanmak istediğiniz başka bir model
|
| 23 |
+
"messages": [
|
| 24 |
+
{"role": "system", "content": "Senin ismin Cortex. Sen kullanıcı dostu bir asistansın."},
|
| 25 |
+
{"role": "user", "content": user_input}
|
| 26 |
+
]
|
| 27 |
+
}
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# Yanıtı işleme
|
| 31 |
+
if response.status_code == 200:
|
| 32 |
+
data = response.json()
|
| 33 |
+
bot_response = data['choices'][0]['message']['content']
|
| 34 |
+
st.text_area("Cortex:", value=bot_response, height=200)
|
| 35 |
+
else:
|
| 36 |
+
st.write(f"Bir hata oluştu: {response.status_code}")
|
| 37 |
+
else:
|
| 38 |
+
st.write("Lütfen bir mesaj girin.")
|
index.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Chat with Cortex</title>
|
| 7 |
-
<link rel="stylesheet" href="styles.css">
|
| 8 |
-
</head>
|
| 9 |
-
<body>
|
| 10 |
-
<div class="chat-container">
|
| 11 |
-
<div id="chat-box" class="chat-box"></div>
|
| 12 |
-
<input type="text" id="user-input" placeholder="Type your message here...">
|
| 13 |
-
<button id="send-btn">Send</button>
|
| 14 |
-
</div>
|
| 15 |
-
|
| 16 |
-
<script src="script.js"></script>
|
| 17 |
-
</body>
|
| 18 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|