MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / test_openai_embeddings

Function test_openai_embeddings

tests/rust_unit_tests/embedding_tests.rs:65–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63#[tokio::test]
64#[ignore = "Requires OpenAI API key (set OPENAI_API_KEY environment variable to run)"]
65async fn test_openai_embeddings() {
66 if !has_openai_key() {
67 return;
68 }
69
70 let config = EmbeddingConfig {
71 provider: EmbeddingProvider::OpenAI,
72 api_key: std::env::var("OPENAI_API_KEY").unwrap(),
73 model: "text-embedding-ada-002".to_string(),
74 base_url: None,
75 timeout_seconds: None,
76 max_batch_size: Some(1),
77 extra_params: HashMap::new(),
78 python_instance: None,
79 };
80
81 let service = EmbeddingService::new(config).unwrap();
82 let result = service.embed_text("test text").await;
83 assert!(result.is_ok());
84 assert!(!result.unwrap().is_empty());
85}
86
87#[tokio::test]
88#[ignore = "Requires HuggingFace API key (set HUGGINGFACE_API_KEY environment variable to run)"]

Callers

nothing calls this directly

Calls 3

to_stringMethod · 0.80
embed_textMethod · 0.80
has_openai_keyFunction · 0.70

Tested by

no test coverage detected