#https://huggingface.co/spaces/osanseviero/mistral-super-fast #https://huggingface.co/blog/llama31 import requests import json def send_request_to_flask(prompt, history, temperature=0.7, max_new_tokens=100, top_p=0.9, repetition_penalty=1.2): # URL of the Flask endpoint #url = "https://jikoni-llamasms.hf.space/generate" # Adjust the URL if needed url = "https://jikoni-llamasms.hf.space/sms" # Create the payload payload = { "prompt": prompt, "history": history, "temperature": temperature, "max_new_tokens": max_new_tokens, "top_p": top_p, "repetition_penalty": repetition_penalty } try: # Send the POST request response = requests.post(url, json=payload) # Check if the request was successful if response.status_code == 200: result = response.json() return result["response"] else: print("Failed to get response from Flask app.") print("Status Code:", response.status_code) print("Response Text:", response.text) return None except requests.RequestException as e: print("An error occurred:", e) return None if __name__ == "__main__": history = [] # Initialize an empty history list while True: # Prompt the user for input prompt = input("You:") if prompt.lower() in ['exit', 'quit', 'stop']: print("Exiting the chat.") break # Send request and get response response_text = send_request_to_flask(prompt, history) if response_text: print(f"\nSema ai: {response_text}\n") # Update history history.append((prompt, response_text)) else: print("No response received.")