InventorsHub commited on
Commit
0ff17d8
·
verified ·
1 Parent(s): f26d471

Update bt_generator.py

Browse files
Files changed (1) hide show
  1. bt_generator.py +10 -6
bt_generator.py CHANGED
@@ -4,13 +4,9 @@ from llama_cpp import Llama
4
  import textwrap
5
  import re
6
  import spaces
 
7
 
8
  # Download only the behavior-tree model shard
9
- model_path = hf_hub_download(
10
- repo_id="Inventors-Hub/SwarmChat-models",
11
- repo_type="model",
12
- filename="Falcon3-10B-Instruct-BehaviorTree-3epochs.Q4_K_M.gguf",
13
- )
14
 
15
 
16
  # llm = Llama(model_path=model_path, n_ctx=1024*4)
@@ -22,10 +18,17 @@ model_path = hf_hub_download(
22
  # use_mmap=True, # mmap file
23
  # use_mlock=False,
24
  # )
25
- llm = None
26
 
27
  @spaces.GPU
 
28
  def gpu_llm():
 
 
 
 
 
 
29
  llm = Llama(
30
  model_path=model_path,
31
  n_ctx=1024*4, # down from 4096
@@ -111,6 +114,7 @@ def generate_behavior_tree(task_prompt: str) -> str:
111
  prompt = construct_prompt(task_prompt)
112
 
113
  print("\n\n",prompt,"\n\n")
 
114
 
115
  output = llm(
116
  prompt,
 
4
  import textwrap
5
  import re
6
  import spaces
7
+ import functools
8
 
9
  # Download only the behavior-tree model shard
 
 
 
 
 
10
 
11
 
12
  # llm = Llama(model_path=model_path, n_ctx=1024*4)
 
18
  # use_mmap=True, # mmap file
19
  # use_mlock=False,
20
  # )
21
+
22
 
23
  @spaces.GPU
24
+ @functools.lru_cache(maxsize=1)
25
  def gpu_llm():
26
+ model_path = hf_hub_download(
27
+ repo_id="Inventors-Hub/SwarmChat-models",
28
+ repo_type="model",
29
+ filename="Falcon3-10B-Instruct-BehaviorTree-3epochs.Q4_K_M.gguf",
30
+ )
31
+
32
  llm = Llama(
33
  model_path=model_path,
34
  n_ctx=1024*4, # down from 4096
 
114
  prompt = construct_prompt(task_prompt)
115
 
116
  print("\n\n",prompt,"\n\n")
117
+ llm = gpu_llm()
118
 
119
  output = llm(
120
  prompt,