github zilliztech/GPTCache 0.1.19
v0.1.19

latest releases: 0.1.44, 0.1.43, 0.1.42...
17 months ago

🎉 Introduction to new functions of GPTCache

  1. Add stability sdk adapter (text -> image)
import os
import time

from gptcache import cache
from gptcache.processor.pre import get_prompt
from gptcache.adapter.stability_sdk import StabilityInference, generation
from gptcache.embedding import Onnx
from gptcache.manager.factory import manager_factory
from gptcache.similarity_evaluation.distance import SearchDistanceEvaluation

# init gptcache
onnx = Onnx()
data_manager = manager_factory('sqlite,faiss,local', 
                               data_dir='./', 
                               vector_params={'dimension': onnx.dimension},
                               object_params={'path': './images'}
                               )
cache.init(
    pre_embedding_func=get_prompt,
    embedding_func=onnx.to_embeddings,
    data_manager=data_manager,
    similarity_evaluation=SearchDistanceEvaluation()
    )

api_key = os.getenv('STABILITY_KEY', 'key-goes-here')

stability_api = StabilityInference(
    key=os.environ['STABILITY_KEY'], # API Key reference.
    verbose=False, # Print debug messages.
    engine='stable-diffusion-xl-beta-v2-2-2', # Set the engine to use for generation.
)

start = time.time()
answers = stability_api.generate(
    prompt='a cat sitting besides a dog',
    width=256,
    height=256
    )

stability reference: https://platform.stability.ai/docs/features/text-to-image

  1. Add minigpt4 adapter

Notice: It cannot be used directly, it needs to cooperate with mini-GPT4 source code, refer to: Vision-CAIR/MiniGPT-4#136

What's Changed

  • Unify the format of manager variable names in manager_factory method by @SimFG in #276
  • Adapt stability_sdk by @jaelgu in #277
  • Add minigpt4 adapter by @shiyu22 in #274
  • Update docs by @jaelgu in #278
  • Make np evaluation positively correlated with the similarity. by @wxywb in #280
  • Add temperature_softmax in post processor by @jaelgu in #282
  • Update the version to 0.1.19 by @SimFG in #283

Full Changelog: 0.1.18...0.1.19

Don't miss a new GPTCache release

NewReleases is sending notifications on new releases.