Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirushikesh committed Oct 1, 2024
1 parent 51713fc commit b3553f8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions notebook/agentchat_huggingface_langchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
},
"source": [
"# Using AutoGen AgentChat with LangChain and Hugging Face\""
"# Using AutoGen AgentChat with LangChain-based Custom Client and Hugging Face Models"
]
},
{
Expand Down Expand Up @@ -162,18 +162,22 @@
"source": [
"# custom client with custom model loader\n",
"\n",
"\n",
"class CustomModelClient:\n",
" \"\"\"Custom model client implementation for LangChain integration with AutoGen.\"\"\"\n",
"\n",
" def __init__(self, config, **kwargs):\n",
" \"\"\"Initialize the CustomModelClient.\"\"\"\n",
" print(f\"CustomModelClient config: {config}\")\n",
" self.device = config.get(\"device\", \"cpu\")\n",
" \n",
"\n",
" gen_config_params = config.get(\"params\", {})\n",
" self.model_name = config[\"model\"]\n",
" pipeline = HuggingFacePipeline.from_model_id(\n",
" model_id=self.model_name, task=\"text-generation\", pipeline_kwargs=gen_config_params,device=self.device,\n",
" model_id=self.model_name,\n",
" task=\"text-generation\",\n",
" pipeline_kwargs=gen_config_params,\n",
" device=self.device,\n",
" )\n",
" self.model = ChatHuggingFace(llm=pipeline)\n",
" print(f\"Loaded model {config['model']} to {self.device}\")\n",
Expand Down Expand Up @@ -318,10 +322,11 @@
"outputs": [],
"source": [
"import getpass\n",
"\n",
"from huggingface_hub import login\n",
"\n",
"# The Mistral-7B-Instruct-v0.2 is a gated model which requires API token to access\n",
"login(token = getpass.getpass(\"Enter your HuggingFace API Token\"))"
"login(token=getpass.getpass(\"Enter your HuggingFace API Token\"))"
]
},
{
Expand Down

0 comments on commit b3553f8

Please sign in to comment.