Add gitignore file
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.pyo
|
||||
*.pyd
|
||||
*.egg
|
||||
*.egg-info/
|
||||
dist/
|
||||
build/
|
||||
*.env
|
||||
.env
|
||||
|
||||
# Virtual environments
|
||||
venv/
|
||||
env/
|
||||
.venv/
|
||||
.env/
|
||||
|
||||
# Jupyter Notebook checkpoints
|
||||
.ipynb_checkpoints/
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
# Node.js
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Build files
|
||||
dist/
|
||||
build/
|
||||
*.lock
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# IDEs and editors
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*.swn
|
||||
*.bak
|
||||
|
||||
# OS-specific files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
@@ -1,54 +0,0 @@
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import requests
|
||||
import redis
|
||||
import json
|
||||
|
||||
r = redis.Redis(host='localhost', port=6379, db=0)
|
||||
|
||||
def save_chat(user_id, message):
|
||||
r.rpush(f"chat:{user_id}", json.dumps(message))
|
||||
|
||||
def get_chat(user_id):
|
||||
messages = r.lrange(f"chat:{user_id}", 0, -1)
|
||||
return [json.loads(m.decode('utf-8')) for m in messages]
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# Allow frontend access
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Store sessions in memory (simple version)
|
||||
sessions = {}
|
||||
|
||||
@app.post("/chat")
|
||||
async def chat(request: Request):
|
||||
data = await request.json()
|
||||
user_id = data.get("user_id", "default")
|
||||
message = data["message"]
|
||||
|
||||
# Retrieve session history
|
||||
history = sessions.get(user_id, [])
|
||||
history.append({"role": "user", "content": message})
|
||||
|
||||
# Send to LM Studio
|
||||
response = requests.post("http://10.74.83.100:1234/v1/chat/completions", json={
|
||||
#response = requests.post("http://localhost:1234/v1/chat/completions", json={
|
||||
"model": "your-model-name", # Replace with actual model name
|
||||
"messages": history
|
||||
})
|
||||
|
||||
result = response.json()
|
||||
reply = result["choices"][0]["message"]["content"]
|
||||
|
||||
# Append assistant response
|
||||
history.append({"role": "assistant", "content": reply})
|
||||
sessions[user_id] = history
|
||||
|
||||
return {"response": reply}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// vite.config.js
|
||||
module.exports = {
|
||||
server: {
|
||||
allowedHosts: ['chat.egalware.com'],
|
||||
host: '0.0.0.0',
|
||||
port: 5173,
|
||||
strictPort: true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user