Spaces:
Sleeping
Sleeping
Download app.py from Hydra002/Eagle-vision: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/spaces/Hydra002/Eagle-vision/resolve/main/app.py
- Command line
-
hf download hf://spaces/Hydra002/Eagle-vision/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Hydra002/Eagle-vision/resolve/main/app.py
2.36 kB
| import gradio as gr | |
| import spaces | |
| import re | |
| from huggingface_hub import hf_hub_download | |
| from llama_cpp import Llama | |
| MODEL_REPO = "HauhauCS/Qwen3.5-9B-Uncensored-HauhauCS-Aggressive" | |
| MODEL_FILE = "Qwen3.5-9B-Uncensored-HauhauCS-Aggressive-Q4_K_M.gguf" | |
| SYSTEM_PROMPT = """You are Eagle Vision, a highly sophisticated AI intelligence entity model. | |
| Answer naturally, clearly, accurately, and completely. | |
| Respond in the same language used by the user. | |
| Maintain conversational continuity and do not unnecessarily shorten answers.""" | |
| llm = None | |
| def load_model(): | |
| global llm | |
| if llm is None: | |
| model_path = hf_hub_download( | |
| repo_id=MODEL_REPO, | |
| filename=MODEL_FILE | |
| ) | |
| llm = Llama( | |
| model_path=model_path, | |
| n_ctx=8192, | |
| n_gpu_layers=-1, | |
| verbose=False | |
| ) | |
| return llm | |
| def eagle_vision(message, history): | |
| model = load_model() | |
| messages = [ | |
| { | |
| "role": "system", | |
| "content": SYSTEM_PROMPT | |
| } | |
| ] | |
| for user_message, assistant_message in history: | |
| messages.append({ | |
| "role": "user", | |
| "content": user_message | |
| }) | |
| messages.append({ | |
| "role": "assistant", | |
| "content": assistant_message | |
| }) | |
| messages.append({ | |
| "role": "user", | |
| "content": message | |
| }) | |
| response = model.create_chat_completion( | |
| messages=messages, | |
| max_tokens=2048, | |
| temperature=0.7, | |
| top_p=0.8, | |
| top_k=20 | |
| ) | |
| result = response["choices"][0]["message"] | |
| content = result.get("content", "") | |
| reasoning = result.get("reasoning_content", "") | |
| if not content and reasoning: | |
| content = reasoning | |
| content = re.sub( | |
| r"^\s*Thinking Process:.*?</think>\s*", | |
| "", | |
| content, | |
| flags=re.DOTALL | re.IGNORECASE | |
| ) | |
| content = re.sub( | |
| r"<think>.*?</think>", | |
| "", | |
| content, | |
| flags=re.DOTALL | re.IGNORECASE | |
| ) | |
| content = re.sub( | |
| r"</think>", | |
| "", | |
| content, | |
| flags=re.IGNORECASE | |
| ) | |
| return content.strip() | |
| demo = gr.ChatInterface( | |
| fn=eagle_vision, | |
| title="EAGLE VISION", | |
| description="Universal Intelligence" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |