mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-07 11:35:29 +00:00
Fix : server script error & readme not up to date
This commit is contained in:
parent
01e225a890
commit
07a43d75ab
@ -133,7 +133,7 @@ Note: For Windows or macOS, use ipconfig or ifconfig respectively to find the IP
|
|||||||
Clone the repository and then, run the script `stream_llm.py` in `server/`
|
Clone the repository and then, run the script `stream_llm.py` in `server/`
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
python3 stream_llm.py
|
python3 server_ollama.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2️⃣ **Run it**
|
### 2️⃣ **Run it**
|
||||||
|
@ -10,7 +10,6 @@ log.setLevel(logging.ERROR)
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Shared state with thread-safe locks
|
# Shared state with thread-safe locks
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.model = None
|
self.model = None
|
||||||
@ -38,7 +37,7 @@ class GenerationState:
|
|||||||
|
|
||||||
state = GenerationState()
|
state = GenerationState()
|
||||||
|
|
||||||
def generate_response(history):
|
def generate_response(history): # Only takes history as an argument
|
||||||
global state
|
global state
|
||||||
try:
|
try:
|
||||||
with state.lock:
|
with state.lock:
|
||||||
@ -47,7 +46,7 @@ def generate_response(history):
|
|||||||
state.current_buffer = ""
|
state.current_buffer = ""
|
||||||
|
|
||||||
stream = ollama.chat(
|
stream = ollama.chat(
|
||||||
model=state.model,
|
model=state.model, # Access state.model directly
|
||||||
messages=history,
|
messages=history,
|
||||||
stream=True,
|
stream=True,
|
||||||
)
|
)
|
||||||
@ -76,7 +75,8 @@ def start_generation():
|
|||||||
return jsonify({"error": "Generation already in progress"}), 400
|
return jsonify({"error": "Generation already in progress"}), 400
|
||||||
|
|
||||||
history = data.get('messages', [])
|
history = data.get('messages', [])
|
||||||
threading.Thread(target=generate_response, args=(history, state.model)).start()
|
# Pass only history to the thread
|
||||||
|
threading.Thread(target=generate_response, args=(history,)).start() # Note the comma to make it a single-element tuple
|
||||||
return jsonify({"message": "Generation started"}), 202
|
return jsonify({"message": "Generation started"}), 202
|
||||||
|
|
||||||
@app.route('/get_updated_sentence')
|
@app.route('/get_updated_sentence')
|
||||||
@ -93,4 +93,4 @@ if __name__ == '__main__':
|
|||||||
config.load()
|
config.load()
|
||||||
config.validate_model(config.model_name)
|
config.validate_model(config.model_name)
|
||||||
state.model = config.model_name
|
state.model = config.model_name
|
||||||
app.run(host='0.0.0.0', port=5000, debug=False, threaded=True)
|
app.run(host='0.0.0.0', port=5001, debug=False, threaded=True)
|
Loading…
x
Reference in New Issue
Block a user