Skip to content

Python scraper based on AI

add api_key as parameter instead of .env file

VinciGit00c02203068e32
diff --git a/README.md b/README.md
index 8e75eee3..ae281262 100644
--- a/README.md
+++ b/README.md
@@ -16,11 +16,19 @@ The reference page for Scrapegraph-ai is avaible on the official page of pypy: [
pip install scrapegraphai
```
## πŸ” Demo
+Official streamlit demo:
-Try out ScrapeGraphAI in your browser:
+[![My Skills](https://skillicons.dev/icons?i=react)](https://scrapegraphaimockup.streamlit.app/)
+
+Is it possible to try also the colab version
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing)
+Try out ScrapeGraphAI in your browser:
+
+[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/VinciGit00/Scrapegraph-ai)
+
+
## πŸ“– Documentation
The documentation for ScrapeGraphAI can be found [here](https://scrapegraph-ai.readthedocs.io/en/latest/).
@@ -78,10 +86,13 @@ For more information, please see the [contributing guidelines](https://github.co
Join our Discord server to discuss with us improvements and give us suggestions!
-[![Join Discord Server](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/DujC7HG8)
-
+[![My Skills](https://skillicons.dev/icons?i=discord)](https://discord.gg/DujC7HG8)
+
+
You can also follow all the updates on linkedin!
-[![Linkedin Badge](https://img.shields.io/badge/-Linkedin-blue?style=flat&logo=Linkedin&logoColor=white)](https://www.linkedin.com/company/scrapegraphai/)
+
+[![My Skills](https://skillicons.dev/icons?i=linkedin)](https://www.linkedin.com/company/scrapegraphai/)
+
## Contributors
[![Contributors](https://contrib.rocks/image?repo=VinciGit00/Scrapegraph-ai)](https://github.com/VinciGit00/Scrapegraph-ai/graphs/contributors)
diff --git a/scrapegraphai/evaluetor/trulens_evaluetor.py b/scrapegraphai/evaluetor/trulens_evaluetor.py
index 88b1756e..17e3ec5e 100644
--- a/scrapegraphai/evaluetor/trulens_evaluetor.py
+++ b/scrapegraphai/evaluetor/trulens_evaluetor.py
@@ -1,7 +1,8 @@
-import os
-from scrapegraphai.graphs import SmartScraperGraph
-from openai import OpenAI
+"""Module for making the RAG"""
from trulens_eval import Feedback, OpenAI as fOpenAI, Tru, Provider, Select, TruBasicApp
+from openai import OpenAI
+from scrapegraphai.graphs import SmartScraperGraph
+
class TrulensEvaluator:
"""
@@ -16,20 +17,27 @@ class TrulensEvaluator:
llm_standalone: Standalone function for Trulens evaluation.
"""
- def __init__(self):
+ def __init__(self, key: str):
+ """
+ Initialization of the class
+ Arguments:
+ - key (str): openai key
+ """
standalone = StandAlone()
f_custom_function = Feedback(standalone.json_complaint).on(
my_text_field=Select.RecordOutput
)
- os.environ["OPENAI_API_KEY"] = os.environ["OPENAI_APIKEY"]
- client = OpenAI()
+ client = OpenAI(api_key=key)
tru = Tru()
tru.reset_database()
fopenai = fOpenAI()
f_relevance = Feedback(self.fopenai.relevance).on_input_output()
- tru_llm_standalone_recorder = TruBasicApp(self.llm_standalone, app_id="smart_scraper_evaluator", feedbacks=[self.f_relevance, self.f_custom_function])
+ tru_llm_standalone_recorder = TruBasicApp(self.llm_standalone,
+ app_id="smart_scraper_evaluator",
+ feedbacks=[self.f_relevance,
+ self.f_custom_function])
- def evaluate(self, graph_params : list[tuple[str, str, dict]]):
+ def evaluate(self, graph_params: list[tuple[str, str, dict]]):
"""
Evaluates Trulens using SmartScraperGraph and starts the dashboard.
@@ -59,13 +67,18 @@ class TrulensEvaluator:
print(f"Prompt: {prompt}")
return str(response)
-"""
-Class for standalone Trulens evaluation. Personalise
-"""
+
class StandAlone(Provider):
+ """
+ Class for standalone Trulens evaluation.
+ """
+
def json_complaint(self, my_text_field: str) -> float:
+ """
+ Args:
+ - my_text_field (str): textfield
+ """
if '{' in my_text_field and '}' in my_text_field and ':' in my_text_field:
return 1.0
else:
return 0.0
-