mirror of
https://github.com/open-webui/pipelines
synced 2025-06-26 01:56:00 +00:00
enh: examples
This commit is contained in:
parent
9e58c71509
commit
e7e0ab120f
@ -54,7 +54,10 @@ class Pipeline:
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
return [
|
||||
{"id": "litellm", "name": "Please configure LiteLLM URL"},
|
||||
{
|
||||
"id": self.id,
|
||||
"name": "Could not fetch models from LiteLLM, please update the URL in the valves.",
|
||||
},
|
||||
]
|
||||
else:
|
||||
return []
|
||||
|
@ -23,7 +23,7 @@ class Pipeline:
|
||||
class Valves(BaseModel):
|
||||
OLLAMA_BASE_URL: str
|
||||
|
||||
self.valves = Valves(**{"OLLAMA_BASE_URL": "http://localhost:11434"})
|
||||
self.valves = Valves(**{"OLLAMA_BASE_URL": "http://localhost:11435"})
|
||||
self.pipelines = []
|
||||
pass
|
||||
|
||||
@ -39,12 +39,24 @@ class Pipeline:
|
||||
pass
|
||||
|
||||
def get_ollama_models(self):
|
||||
r = requests.get(f"{self.valves.OLLAMA_BASE_URL}/api/tags")
|
||||
models = r.json()
|
||||
|
||||
return [
|
||||
{"id": model["model"], "name": model["name"]} for model in models["models"]
|
||||
]
|
||||
if self.valves.OLLAMA_BASE_URL:
|
||||
try:
|
||||
r = requests.get(f"{self.valves.OLLAMA_BASE_URL}/api/tags")
|
||||
models = r.json()
|
||||
return [
|
||||
{"id": model["model"], "name": model["name"]}
|
||||
for model in models["models"]
|
||||
]
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
return [
|
||||
{
|
||||
"id": self.id,
|
||||
"name": "Could not fetch models from Ollama, please update the URL in the valves.",
|
||||
},
|
||||
]
|
||||
else:
|
||||
return []
|
||||
|
||||
def pipe(
|
||||
self, user_message: str, model_id: str, messages: List[dict], body: dict
|
||||
|
@ -23,7 +23,7 @@ class Pipeline:
|
||||
class Valves(BaseModel):
|
||||
OLLAMA_BASE_URL: str
|
||||
|
||||
self.valves = Valves(**{"OLLAMA_BASE_URL": "http://localhost:11434"})
|
||||
self.valves = Valves(**{"OLLAMA_BASE_URL": "http://localhost:11435"})
|
||||
self.pipelines = []
|
||||
pass
|
||||
|
||||
@ -39,12 +39,24 @@ class Pipeline:
|
||||
pass
|
||||
|
||||
def get_ollama_models(self):
|
||||
r = requests.get(f"{self.valves.OLLAMA_BASE_URL}/api/tags")
|
||||
models = r.json()
|
||||
|
||||
return [
|
||||
{"id": model["model"], "name": model["name"]} for model in models["models"]
|
||||
]
|
||||
if self.valves.OLLAMA_BASE_URL:
|
||||
try:
|
||||
r = requests.get(f"{self.valves.OLLAMA_BASE_URL}/api/tags")
|
||||
models = r.json()
|
||||
return [
|
||||
{"id": model["model"], "name": model["name"]}
|
||||
for model in models["models"]
|
||||
]
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
return [
|
||||
{
|
||||
"id": self.id,
|
||||
"name": "Could not fetch models from Ollama, please update the URL in the valves.",
|
||||
},
|
||||
]
|
||||
else:
|
||||
return []
|
||||
|
||||
def pipe(
|
||||
self, user_message: str, model_id: str, messages: List[dict], body: dict
|
||||
|
Loading…
Reference in New Issue
Block a user