diff --git a/addons/godot_llama/demo/demo_wasm.gd b/addons/godot_llama/demo/demo_wasm.gd index fc0a4de..abb4e1b 100644 --- a/addons/godot_llama/demo/demo_wasm.gd +++ b/addons/godot_llama/demo/demo_wasm.gd @@ -8,10 +8,7 @@ extends Control @onready var generate_button: Button = $MarginContainer/Scroll/VBox/GenerateRow/GenerateButton @onready var helper = $VBoxContainer/SubViewportContainer/SubViewport/base_node/helper -const API_URL := "https://apphubai.wolke.uni-greifswald.de/v1" #TODO insert your url to the llm / api-gateway here -const API_TOKEN := "" -const API_MODEL := "unsloth/gemma-4-31B-it-qat-GGUF:UD-Q4_K_XL" -const MAX_RESPONSE_TOKENS := 200 +const API_URL := "" var document_id signal closing_chatbot @@ -51,20 +48,11 @@ func _on_generate_pressed() -> void: combined_user_message = "Dokument:\n%s\n\nFrage: %s" % [document, user_text] var body := { - "model": API_MODEL, - "messages": [ - {"role": "system", "content": tr("CHATBOT_SYSTEM_PROMPT")}, - {"role": "user", "content": combined_user_message}, - ], - "max_tokens": MAX_RESPONSE_TOKENS, - "temperature": 0.1, + "question": combined_user_message, + "prompt": tr("CHATBOT_SYSTEM_PROMPT"), } - var headers := PackedStringArray([ - "Content-Type: application/json", - "Authorization: Bearer %s" % API_TOKEN, - ]) - var endpoint := API_URL.trim_suffix("/") + "/chat/completions" - var err := _http.request(endpoint, headers, HTTPClient.METHOD_POST, JSON.stringify(body)) + var headers := PackedStringArray(["Content-Type: application/json"]) + var err := _http.request(API_URL, headers, HTTPClient.METHOD_POST, JSON.stringify(body)) if err != OK: _stop_helper_animation() output_text.text = _request_failed("HTTP %s" % error_string(err)) @@ -105,14 +93,8 @@ func _on_request_completed( func _extract_reply(json) -> String: if typeof(json) != TYPE_DICTIONARY: return "" - if json.has("choices") and json["choices"] is Array and not json["choices"].is_empty(): - var choice = json["choices"][0] - if choice is Dictionary and choice.get("message") is Dictionary: - return str(choice["message"].get("content", "")).strip_edges() if json.has("content"): return str(json["content"]).strip_edges() - if json.get("message") is Dictionary: - return str(json["message"].get("content", "")).strip_edges() return "" func _request_failed(detail: String) -> String: