Skip to content

Instantly share code, notes, and snippets.

@mazaira
Created January 26, 2024 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazaira/aeb9a74f70ddbffa44ec5b67a7385871 to your computer and use it in GitHub Desktop.
Save mazaira/aeb9a74f70ddbffa44ec5b67a7385871 to your computer and use it in GitHub Desktop.
Ruby Client Privategpt
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