Commit ccae1803 authored by JinyuanSun's avatar JinyuanSun
Browse files

small bug fix

parent e376064b
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -8,7 +8,6 @@ from typing import Dict, List, Optional, Literal, Union
from datetime import datetime
from datetime import datetime
from pymol import cmd
from pymol import cmd



class PyMOLCommandHandler(http.server.BaseHTTPRequestHandler):
class PyMOLCommandHandler(http.server.BaseHTTPRequestHandler):


    def __init__(self):
    def __init__(self):
@@ -78,7 +77,7 @@ class PyMOLAgent:
    def __init__(
    def __init__(
        self,
        self,
        model: str = "gpt-4o",
        model: str = "gpt-4o",
        provider: Optional[Literal["openai", "anthropic"]] = None,
        provider: Optional[Literal["openai", "anthropic", "deepseek"]] = None,
        system_message: Optional[str] = None,
        system_message: Optional[str] = None,
    ):
    ):
        self.config_dir = os.path.expanduser("~/.PyMOL")
        self.config_dir = os.path.expanduser("~/.PyMOL")
@@ -93,7 +92,7 @@ class PyMOLAgent:
        self.api_key = self.get_api_key()
        self.api_key = self.get_api_key()
        
        
        if not self.api_key:
        if not self.api_key:
            raise ValueError(f"Please set {'ANTHROPIC' if self.provider == 'anthropic' else 'OPENAI'}_API_KEY environment variable or configure it in {self.config_file}")
            Warning(f"Please set {'ANTHROPIC' if self.provider == 'anthropic' else 'OPENAI'}_API_KEY environment variable or configure it in {self.config_file}")


        self.system_message = system_message or """You are a PyMOL expert assistant, specialized in providing command line code solutions related to PyMOL. 
        self.system_message = system_message or """You are a PyMOL expert assistant, specialized in providing command line code solutions related to PyMOL. 
Generate clear and effective solutions. 
Generate clear and effective solutions. 
+1 −1
Original line number Original line Diff line number Diff line
@@ -351,7 +351,7 @@ class ConversationHandler:
                        "content": function_response,
                        "content": function_response,
                    }
                    }
                )
                )
            second_response = client.chat.completions.create(
            second_response = self.client.chat.completions.create(
                model=self.model_name,
                model=self.model_name,
                messages=self.messages,
                messages=self.messages,
            )  # get a new response from the model where it can see the function response
            )  # get a new response from the model where it can see the function response