Eladlev / AutoPrompt

A framework for prompt tuning using Intent-based Prompt Calibration
Apache License 2.0
1.86k stars 149 forks source link

Argilla server 404 #47

Closed xyifhgvnlo286 closed 4 months ago

xyifhgvnlo286 commented 4 months ago

Argilla server version 1.25.0 I have updated the code repository to the latest version. I see that the client version is also 1.25.0, but the service started well and reported the following error:

┌───────────────────── Traceback (most recent call last) ─────────────────────┐
│ C:\code\owncode\AutoPrompt\run_pipeline.py:44 in <module>                   │
│                                                                             │
│   41 pipeline = OptimizationPipeline(config_params, task_description, initi │
│   42 if (opt.load_path != ''):                                              │
│   43 │   pipeline.load_state(opt.load_path)                                 │
│ > 44 best_prompt = pipeline.run_pipeline(opt.num_steps)                     │
│   45 print('\033[92m' + 'Calibrated prompt score:', str(best_prompt['score' │
│   46 print('\033[92m' + 'Calibrated prompt:', best_prompt['prompt'] + '\033 │
│   47                                                                        │
│                                                                             │
│ C:\code\owncode\AutoPrompt\optimization_pipeline.py:272 in run_pipeline     │
│                                                                             │
│   269 │   │   # Run the optimization pipeline for num_steps                 │
│   270 │   │   num_steps_remaining = num_steps - self.batch_id               │
│   271 │   │   for i in range(num_steps_remaining):                          │
│ > 272 │   │   │   stop_criteria = self.step()                               │
│   273 │   │   │   if stop_criteria:                                         │
│   274 │   │   │   │   break                                                 │
│   275 │   │   final_result = self.extract_best_prompt()                     │
│                                                                             │
│ C:\code\owncode\AutoPrompt\optimization_pipeline.py:240 in step             │
│                                                                             │
│   237 │   │   │   │   step=self.batch_id)                                   │
│   238 │   │                                                                 │
│   239 │   │   logging.info('Running annotator')                             │
│ > 240 │   │   records = self.annotator.apply(self.dataset, self.batch_id)   │
│   241 │   │   self.dataset.update(records)                                  │
│   242 │   │                                                                 │
│   243 │   │   self.predictor.cur_instruct = self.cur_prompt                 │
│                                                                             │
│ C:\code\owncode\AutoPrompt\estimator\estimator_argilla.py:106 in apply      │
│                                                                             │
│   103 │   │   webbrowser.open(url_link)                                     │
│   104 │   │   while True:                                                   │
│   105 │   │   │   query = "(status:Validated OR status:Discarded) AND metad │
│ > 106 │   │   │   search_results = current_api.search.search_records(       │
│   107 │   │   │   │   name=dataset.name,                                    │
│   108 │   │   │   │   task=rg_dataset.task,                                 │
│   109 │   │   │   │   size=0,                                               │
│                                                                             │
│ C:\code\owncode\AutoPrompt\venv\Lib\site-packages\argilla\client\apis\searc │
│ h.py:76 in search_records                                                   │
│                                                                             │
│   73 │   │   │   url += f"?limit={size}"                                    │
│   74 │   │                                                                  │
│   75 │   │   query = self._parse_query(query=query)                         │
│ > 76 │   │   response = self.http_client.post(                              │
│   77 │   │   │   path=url,                                                  │
│   78 │   │   │   json={"query": query} if query else None,                  │
│   79 │   │   )                                                              │
│                                                                             │
│ C:\code\owncode\AutoPrompt\venv\Lib\site-packages\argilla\client\sdk\client │
│ .py:124 in inner                                                            │
│                                                                             │
│   121 │   │   @functools.wraps(func)                                        │
│   122 │   │   def inner(self, *args, **kwargs):                             │
│   123 │   │   │   try:                                                      │
│ > 124 │   │   │   │   result = func(self, *args, **kwargs)                  │
│   125 │   │   │   │   return result                                         │
│   126 │   │   │   except httpx.ConnectError as err:                         │
│   127 │   │   │   │   err_str = f"Your Api endpoint at {self.base_url} is n │
│                                                                             │
│ C:\code\owncode\AutoPrompt\venv\Lib\site-packages\argilla\client\sdk\client │
│ .py:191 in post                                                             │
│                                                                             │
│   188 │   │   │   *args,                                                    │
│   189 │   │   │   **kwargs,                                                 │
│   190 │   │   )                                                             │
│ > 191 │   │   return build_raw_response(response).parsed                    │
│   192 │                                                                     │
│   193 │   @with_httpx_error_handler                                         │
│   194 │   def put(                                                          │
│                                                                             │
│ C:\code\owncode\AutoPrompt\venv\Lib\site-packages\argilla\client\sdk\_helpe │
│ rs.py:25 in build_raw_response                                              │
│                                                                             │
│   22                                                                        │
│   23                                                                        │
│   24 def build_raw_response(response: httpx.Response) -> Response[Union[Dic │
│ > 25 │   return build_typed_response(response)                              │
│   26                                                                        │
│   27                                                                        │
│   28 ResponseType = TypeVar("ResponseType")                                 │
│                                                                             │
│ C:\code\owncode\AutoPrompt\venv\Lib\site-packages\argilla\client\sdk\_helpe │
│ rs.py:34 in build_typed_response                                            │
│                                                                             │
│   31 def build_typed_response(                                              │
│   32 │   response: httpx.Response, response_type_class: Optional[Type[Respo │
│   33 ) -> Response[Union[ResponseType, ErrorMessage, HTTPValidationError]]: │
│ > 34 │   parsed_response = check_response(response, expected_response=respo │
│   35 │   if response_type_class:                                            │
│   36 │   │   parsed_response = response_type_class(**parsed_response)       │
│   37 │   return Response(                                                   │
│                                                                             │
│ C:\code\owncode\AutoPrompt\venv\Lib\site-packages\argilla\client\sdk\_helpe │
│ rs.py:63 in check_response                                                  │
│                                                                             │
│   60 │   │   │   message=message,                                           │
│   61 │   │   │   response=response.content,                                 │
│   62 │   │   )                                                              │
│ > 63 │   handle_response_error(response, **kwargs)                          │
│   64                                                                        │
│                                                                             │
│ C:\code\owncode\AutoPrompt\venv\Lib\site-packages\argilla\client\sdk\common │
│ s\errors_handler.py:63 in handle_response_error                             │
│                                                                             │
│   60 │   │   error_type = GenericApiError                                   │
│   61 │   else:                                                              │
│   62 │   │   raise HttpResponseError(response=response)                     │
│ > 63 │   raise error_type(**error_args)                                     │
│   64                                                                        │
└─────────────────────────────────────────────────────────────────────────────┘
NotFoundApiError: Argilla server returned an error with http status: 404. Error
details: {'response': 'Not Found'}
Eladlev commented 4 months ago

Hi, I tested the flow with an Argilla server that was built with the latest docker (argilla/argilla-quickstart:v1.25.0), and it works well. You can test it with a test server that I uploaded (default passwords and settings): https://eladlev-test3.hf.space

xyifhgvnlo286 commented 4 months ago

I've attempted the implementation but encountered a 404 error. Upon debugging, I found that the final request path at estimator/estimator_argilla.py:106 was '/api/datasets/dataset__06_03_2024_16_42_03/TaskType.text_classification:search'. However, it seems there might be an issue with how {task} is being replaced in the API_URL_PATTERN = "/api/datasets/{name}/{task}:search". I'm currently using Python version 3.11.8 and have only made a few changes to the configuration, with no alterations elsewhere in the code. @Eladlev

xyifhgvnlo286 commented 4 months ago

I switched to Python version 3.10.11, and that resolved the issue.

Eladlev commented 4 months ago

Thanks, we will add to the readme a restriction on the python version