Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,7 +103,10 @@ repo_id = "HuggingFaceH4/zephyr-7b-alpha" #das Modell ist echt gut!!! Vom MIT
|
|
| 103 |
MODEL_NAME_HF = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 104 |
MODEL_NAME_OAI_ZEICHNEN = "dall-e-3"
|
| 105 |
#Alternativ zeichnen: Stabe Diffusion from HF:
|
|
|
|
| 106 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1"
|
|
|
|
|
|
|
| 107 |
|
| 108 |
################################################
|
| 109 |
#HF Hub Zugriff ermöglichen
|
|
@@ -435,10 +438,11 @@ def generate_text (prompt, chatbot, history, rag_option, model_option, openai_ap
|
|
| 435 |
#oder an Hugging Face --------------------------
|
| 436 |
print("HF Anfrage.......................")
|
| 437 |
model_kwargs={"temperature": 0.5, "max_length": 512, "num_return_sequences": 1, "top_k": top_k, "top_p": top_p, "repetition_penalty": repetition_penalty}
|
| 438 |
-
llm = HuggingFaceHub(repo_id=repo_id, model_kwargs=model_kwargs)
|
| 439 |
#llm = HuggingFaceChain(model=MODEL_NAME_HF, model_kwargs={"temperature": 0.5, "max_length": 128})
|
| 440 |
#llm = HuggingFaceHub(url_??? = "https://wdgsjd6zf201mufn.us-east-1.aws.endpoints.huggingface.cloud", model_kwargs={"temperature": 0.5, "max_length": 64})
|
| 441 |
#llm = HuggingFaceTextGenInference( inference_server_url="http://localhost:8010/", max_new_tokens=max_new_tokens,top_k=10,top_p=top_p,typical_p=0.95,temperature=temperature,repetition_penalty=repetition_penalty,)
|
|
|
|
| 442 |
print("HF")
|
| 443 |
#Prompt an history anhängen und einen Text daraus machen
|
| 444 |
history_text_und_prompt = generate_prompt_with_history(prompt, history)
|
|
@@ -453,10 +457,18 @@ def generate_text (prompt, chatbot, history, rag_option, model_option, openai_ap
|
|
| 453 |
#db = document_retrieval_mongodb(llm, history_text_und_prompt)
|
| 454 |
#result = rag_chain(llm, history_text_und_prompt, db)
|
| 455 |
else:
|
| 456 |
-
splittet = False
|
| 457 |
print("LLM aufrufen ohne RAG: ...........")
|
| 458 |
-
|
| 459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
|
| 461 |
#Wenn keine Antwort möglich "Ich weiß es nicht" etc., dann versuchen mit Suche im Internet.
|
| 462 |
if (result == None or is_response_similar(result)):
|
|
|
|
| 103 |
MODEL_NAME_HF = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 104 |
MODEL_NAME_OAI_ZEICHNEN = "dall-e-3"
|
| 105 |
#Alternativ zeichnen: Stabe Diffusion from HF:
|
| 106 |
+
#Zeichnen
|
| 107 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1"
|
| 108 |
+
#Textgenerierung
|
| 109 |
+
API_URL_TEXT = "https://api-inference.huggingface.co/models/argilla/notux-8x7b-v1"
|
| 110 |
|
| 111 |
################################################
|
| 112 |
#HF Hub Zugriff ermöglichen
|
|
|
|
| 438 |
#oder an Hugging Face --------------------------
|
| 439 |
print("HF Anfrage.......................")
|
| 440 |
model_kwargs={"temperature": 0.5, "max_length": 512, "num_return_sequences": 1, "top_k": top_k, "top_p": top_p, "repetition_penalty": repetition_penalty}
|
| 441 |
+
#llm = HuggingFaceHub(repo_id=repo_id, model_kwargs=model_kwargs)
|
| 442 |
#llm = HuggingFaceChain(model=MODEL_NAME_HF, model_kwargs={"temperature": 0.5, "max_length": 128})
|
| 443 |
#llm = HuggingFaceHub(url_??? = "https://wdgsjd6zf201mufn.us-east-1.aws.endpoints.huggingface.cloud", model_kwargs={"temperature": 0.5, "max_length": 64})
|
| 444 |
#llm = HuggingFaceTextGenInference( inference_server_url="http://localhost:8010/", max_new_tokens=max_new_tokens,top_k=10,top_p=top_p,typical_p=0.95,temperature=temperature,repetition_penalty=repetition_penalty,)
|
| 445 |
+
|
| 446 |
print("HF")
|
| 447 |
#Prompt an history anhängen und einen Text daraus machen
|
| 448 |
history_text_und_prompt = generate_prompt_with_history(prompt, history)
|
|
|
|
| 457 |
#db = document_retrieval_mongodb(llm, history_text_und_prompt)
|
| 458 |
#result = rag_chain(llm, history_text_und_prompt, db)
|
| 459 |
else:
|
| 460 |
+
#splittet = False
|
| 461 |
print("LLM aufrufen ohne RAG: ...........")
|
| 462 |
+
if (model_option == "OpenAI"):
|
| 463 |
+
resulti = llm_chain(llm, history_text_und_prompt)
|
| 464 |
+
result = resulti.strip()
|
| 465 |
+
else:
|
| 466 |
+
data = {"inputs": prompt}
|
| 467 |
+
response = requests.post(API_URL, headers=HEADERS, json=data)
|
| 468 |
+
result = response.json()
|
| 469 |
+
print("result. HF API.....................")
|
| 470 |
+
print(result)
|
| 471 |
+
|
| 472 |
|
| 473 |
#Wenn keine Antwort möglich "Ich weiß es nicht" etc., dann versuchen mit Suche im Internet.
|
| 474 |
if (result == None or is_response_similar(result)):
|