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