Spaces:
Sleeping
Sleeping
Download llm.py from sqfoo/Mini_DungeonGame: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/sqfoo/Mini_DungeonGame/resolve/ccef4f75d3396d2c62de856476f48383c8b7e2d4/llm.py
- Command line
-
hf download hf://spaces/sqfoo/Mini_DungeonGame@ccef4f75d3396d2c62de856476f48383c8b7e2d4/llm.py
-
curl -L -o llm.py https://huggingface.co/spaces/sqfoo/Mini_DungeonGame/resolve/ccef4f75d3396d2c62de856476f48383c8b7e2d4/llm.py
1.08 kB
| from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint | |
| HUGGINGFACE = { | |
| 'type': 'huggingface', | |
| 'param':{ | |
| 'repo_id': "Qwen/Qwen2.5-7B-Instruct", | |
| 'task': 'text-generation', | |
| 'max_new_tokens': 512, | |
| 'do_sample': False, | |
| 'repetition_penalty': 1.03, | |
| 'provider': 'auto', | |
| }, | |
| 'model': 'huggingface:Qwen2.5-7B-Instruct', | |
| } | |
| HUGGINGFACE_LITE = { | |
| 'type': 'huggingface-lite', | |
| 'param':{ | |
| 'repo_id': "Qwen/Qwen2.5-1.5B-Instruct", | |
| 'task': 'text-generation', | |
| 'max_new_tokens': 512, | |
| 'do_sample': False, | |
| 'repetition_penalty': 1.03, | |
| 'provider': 'auto', | |
| }, | |
| 'model': 'huggingface:Qwen2.5-1.5B-Instruct', | |
| } | |
| valid_LLM = [HUGGINGFACE, HUGGINGFACE_LITE] | |
| def setup_model(config: dict, API_KEY: str, callbacks=None): | |
| if config['type'].startswith('huggingface'): | |
| llm = HuggingFaceEndpoint(huggingfacehub_api_token=API_KEY, **config['param']) | |
| model = ChatHuggingFace(llm=llm, callbacks=callbacks) | |
| else: | |
| model = None | |
| return model |