Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 16ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
o

ollama

Recently created Least recently created Recently updated Least recently updated

timmy / Ollama API 客戶端的應用

Last active 6 hours ago AI API LLM NLP ollama python requests

這是一個 OllamaClient 類,用於與 Ollama LLM API 通信,支持發送文字到指定模型處理、添加提示詞,以及獲取可用模型列表,並內建錯誤處理和超時設定。

0 0 0 2
1 import requests
2
3
4 class OllamaClient:
5 def __init__(self, api_url, api_key=None, timeout=30):
6 """
7 初始化 OllamaClient。
8
9 :param api_url: API 基本端點,例如 'http://192.168.88.82:11434'
10 :param api_key: 如果需要身份驗證,填入 API 金鑰;否則為 None。