Spaces:
Sleeping
Sleeping
changed class interface with iterator
Browse files- interface.py +4 -3
interface.py
CHANGED
@@ -11,7 +11,7 @@ from pydantic import Field, field_validator
|
|
11 |
class GemmaLLMInterface(CustomLLM):
|
12 |
def __init__(self, model_id: str = "google/gemma-2-2b-it", **kwargs):
|
13 |
super().__init__(**kwargs)
|
14 |
-
self
|
15 |
self.model = AutoModelForCausalLM.from_pretrained(
|
16 |
self.model_id,
|
17 |
device_map="auto",
|
@@ -32,9 +32,10 @@ class GemmaLLMInterface(CustomLLM):
|
|
32 |
return LLMMetadata(
|
33 |
context_window=self.context_window,
|
34 |
num_output=self.num_output,
|
35 |
-
model_name=self.model_id,
|
36 |
)
|
37 |
-
|
|
|
38 |
@llm_completion_callback()
|
39 |
def complete(self, prompt: str, **kwargs: Any) -> CompletionResponse:
|
40 |
prompt = self._format_prompt(prompt)
|
|
|
11 |
class GemmaLLMInterface(CustomLLM):
|
12 |
def __init__(self, model_id: str = "google/gemma-2-2b-it", **kwargs):
|
13 |
super().__init__(**kwargs)
|
14 |
+
object.__setattr__(self, "model_id", model_id) # Use object.__setattr__ to bypass Pydantic restrictions
|
15 |
self.model = AutoModelForCausalLM.from_pretrained(
|
16 |
self.model_id,
|
17 |
device_map="auto",
|
|
|
32 |
return LLMMetadata(
|
33 |
context_window=self.context_window,
|
34 |
num_output=self.num_output,
|
35 |
+
model_name=self.model_id, # Passing the correct model ID here
|
36 |
)
|
37 |
+
|
38 |
+
|
39 |
@llm_completion_callback()
|
40 |
def complete(self, prompt: str, **kwargs: Any) -> CompletionResponse:
|
41 |
prompt = self._format_prompt(prompt)
|