charan-ml commited on
Commit
b6392ce
·
1 Parent(s): 65fcecf

fix: cast model_path and prompt to string to resolve ValueError('not a string')

Browse files
Files changed (1) hide show
  1. inference.py +4 -4
inference.py CHANGED
@@ -50,10 +50,10 @@ def load_model():
50
  "llama-cpp-python is not installed. "
51
  "Add it to hf_space/requirements.txt."
52
  )
53
- model_path = hf_hub_download(
54
  repo_id=MODEL_REPO,
55
  filename=MODEL_FILE
56
- )
57
 
58
  _llm = Llama(
59
  model_path=model_path,
@@ -69,7 +69,7 @@ def generate_text(model_name: str, prompt: str, max_new_tokens: int = 512) -> st
69
  llm = load_model()
70
 
71
  output = llm(
72
- prompt,
73
  max_tokens=max_new_tokens,
74
  temperature=0.7,
75
  top_p=0.95
@@ -90,7 +90,7 @@ def generate_with_image(prompt: str, image_base64: str, max_new_tokens: int = 51
90
  text_prompt = f"{prompt}\n\n[Image provided]"
91
 
92
  output = llm(
93
- text_prompt,
94
  max_tokens=max_new_tokens,
95
  temperature=0.7,
96
  top_p=0.95
 
50
  "llama-cpp-python is not installed. "
51
  "Add it to hf_space/requirements.txt."
52
  )
53
+ model_path = str(hf_hub_download(
54
  repo_id=MODEL_REPO,
55
  filename=MODEL_FILE
56
+ ))
57
 
58
  _llm = Llama(
59
  model_path=model_path,
 
69
  llm = load_model()
70
 
71
  output = llm(
72
+ str(prompt),
73
  max_tokens=max_new_tokens,
74
  temperature=0.7,
75
  top_p=0.95
 
90
  text_prompt = f"{prompt}\n\n[Image provided]"
91
 
92
  output = llm(
93
+ str(text_prompt),
94
  max_tokens=max_new_tokens,
95
  temperature=0.7,
96
  top_p=0.95