fix error weaviate vector (#1058)

Co-authored-by: jyong <jyong@dify.ai>
This commit is contained in:
Jyong 2023-08-30 20:34:17 +08:00 committed by GitHub
parent e34dcc0406
commit 7df56ed617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -329,16 +329,23 @@ def create_qdrant_indexes():
model_name=dataset.embedding_model model_name=dataset.embedding_model
) )
except Exception: except Exception:
provider = Provider( try:
id='provider_id', embedding_model = ModelFactory.get_embedding_model(
tenant_id=dataset.tenant_id, tenant_id=dataset.tenant_id
provider_name='openai', )
provider_type=ProviderType.CUSTOM.value, dataset.embedding_model = embedding_model.name
encrypted_config=json.dumps({'openai_api_key': 'TEST'}), dataset.embedding_model_provider = embedding_model.model_provider.provider_name
is_valid=True, except Exception:
) provider = Provider(
model_provider = OpenAIProvider(provider=provider) id='provider_id',
embedding_model = OpenAIEmbedding(name="text-embedding-ada-002", model_provider=model_provider) tenant_id=dataset.tenant_id,
provider_name='openai',
provider_type=ProviderType.SYSTEM.value,
encrypted_config=json.dumps({'openai_api_key': 'TEST'}),
is_valid=True,
)
model_provider = OpenAIProvider(provider=provider)
embedding_model = OpenAIEmbedding(name="text-embedding-ada-002", model_provider=model_provider)
embeddings = CacheEmbedding(embedding_model) embeddings = CacheEmbedding(embedding_model)
from core.index.vector_index.qdrant_vector_index import QdrantVectorIndex, QdrantConfig from core.index.vector_index.qdrant_vector_index import QdrantVectorIndex, QdrantConfig