Created
January 26, 2024 07:27
-
-
Save mazaira/aeb9a74f70ddbffa44ec5b67a7385871 to your computer and use it in GitHub Desktop.
Ruby Client Privategpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
require 'json' | |
class Prclient | |
BASE_URL = 'https://changeme.com/' | |
def initialize | |
@conn = Faraday.new(url: BASE_URL) do |faraday| | |
faraday.request :json | |
faraday.response :json, content_type: /\bjson$/ | |
end | |
end | |
def post_v1_completions(body) | |
@conn.post('/v1/completions', body.to_json) | |
end | |
def post_v1_chat_completions(body) | |
@conn.post('/v1/chat/completions', body.to_json) | |
end | |
def post_v1_chunks(body) | |
@conn.post('/v1/chunks', body.to_json) | |
end | |
def post_v1_ingest_file(body) | |
@conn.post('/v1/ingest/file', body) | |
end | |
def post_v1_ingest_text(body) | |
@conn.post('/v1/ingest/text', body.to_json) | |
end | |
def get_v1_ingest_list | |
@conn.get('/v1/ingest/list') | |
end | |
def delete_v1_ingest_doc(doc_id) | |
@conn.delete("/v1/ingest/#{doc_id}") | |
end | |
def post_v1_embeddings(body) | |
@conn.post('/v1/embeddings', body.to_json) | |
end | |
def get_health | |
@conn.get('/health') | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment