(config_path, load_from=None)
| 6 | |
| 7 | |
| 8 | def get_mirix_client(config_path, load_from=None): |
| 9 | if os.path.exists(os.path.expanduser("~/.mirix")): |
| 10 | os.system("rm -rf ~/.mirix/*") |
| 11 | |
| 12 | with open(config_path) as f: |
| 13 | agent_config = yaml.safe_load(f) |
| 14 | |
| 15 | os.environ["OPENAI_API_KEY"] = agent_config["api_key"] |
| 16 | import mirix |
| 17 | |
| 18 | from mirix import EmbeddingConfig, LLMConfig, Mirix |
| 19 | |
| 20 | embedding_default_config = EmbeddingConfig( |
| 21 | embedding_model=agent_config["embedding_model_name"], |
| 22 | embedding_endpoint_type="openai", |
| 23 | embedding_endpoint=agent_config["model_endpoint"], |
| 24 | embedding_dim=1536, |
| 25 | embedding_chunk_size=8191, |
| 26 | ) |
| 27 | |
| 28 | llm_default_config = LLMConfig( |
| 29 | model=agent_config["model_name"], |
| 30 | model_endpoint_type="openai", |
| 31 | model_endpoint=agent_config["model_endpoint"], |
| 32 | api_key=agent_config["api_key"], |
| 33 | model_wrapper=None, |
| 34 | context_window=128000, |
| 35 | ) |
| 36 | |
| 37 | def embedding_default_config_func(cls, model_name=None, provider=None): |
| 38 | return embedding_default_config |
| 39 | |
| 40 | def llm_default_config_func(cls, model_name=None, provider=None): |
| 41 | return llm_default_config |
| 42 | |
| 43 | mirix.EmbeddingConfig.default_config = embedding_default_config_func |
| 44 | mirix.LLMConfig.default_config = llm_default_config_func |
| 45 | |
| 46 | assistant = Mirix( |
| 47 | api_key=agent_config["api_key"], |
| 48 | config_path=config_path, |
| 49 | model=agent_config["model_name"], |
| 50 | load_from=load_from, |
| 51 | ) |
| 52 | return assistant |
| 53 | |
| 54 | |
| 55 | if __name__ == "__main__": |
no test coverage detected