Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about openai apiky usage #19

Open
demaxiya567 opened this issue Apr 25, 2024 · 0 comments
Open

about openai apiky usage #19

demaxiya567 opened this issue Apr 25, 2024 · 0 comments

Comments

@demaxiya567
Copy link

how can i use the“from langchain_openai import ChatOpenAI” by connect GPT4 and chemlift?when I run the example code by my API key,it always shows this error“ValueError: Sample larger than population or is negative”

ValueError Traceback (most recent call last)
Cell In[6], line 24
21 fsc = FewShotClassifier(client, property_name='bandgap')
23 # Train on a few examples
---> 24 fsc.fit(['ethane', 'propane', 'butane'], [0,1,0])
26 # Predict on a few more
27 fsc.predict(['pentane', 'hexane', 'heptane'])

File c:\Users\19341.conda\envs\agents20240401\Lib\site-packages\chemlift\icl\fewshotpredictor.py:238, in FewShotPredictor.fit(self, X, y)
231 def fit(self, X: ArrayLike, y: ArrayLike):
232 """Fit the model to a support set.
233
234 Args:
235 X: A list of examples.
236 y: A list of targets.
237 """
--> 238 support_indices = self._pick_support_indices(X)
239 self._support_set = (np.array(X)[support_indices], np.array(y)[support_indices])
240 self._allowed_values = set(y)

File c:\Users\19341.conda\envs\agents20240401\Lib\site-packages\chemlift\icl\fewshotpredictor.py:118, in FewShotPredictor._pick_support_indices(self, examples)
116 random.seed(self._seed)
117 if self._strategy == Strategy.RANDOM:
--> 118 return random.sample(range(len(examples)), self._n_support)
119 elif self._strategy == Strategy.FIRST:
120 return list(range(self._n_support))

File c:\Users\19341.conda\envs\agents20240401\Lib\random.py:456, in Random.sample(self, population, k, counts)
454 randbelow = self._randbelow
455 if not 0 <= k <= n:
--> 456 raise ValueError("Sample larger than population or is negative")
457 result = [None] * k
458 setsize = 21 # size of a small set minus size of an empty list

ValueError: Sample larger than population or is negative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant