Skip to content

Commit c022030

Browse files
committed
add api_key as parameter instead of .env file
1 parent ca909cf commit c022030

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

README.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ The reference page for Scrapegraph-ai is avaible on the official page of pypy: [
1616
pip install scrapegraphai
1717
```
1818
## 🔍 Demo
19+
Official streamlit demo:
1920

20-
Try out ScrapeGraphAI in your browser:
21+
[![My Skills](https://skillicons.dev/icons?i=react)](https://scrapegraphaimockup.streamlit.app/)
22+
23+
Is it possible to try also the colab version
2124

2225
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing)
2326

27+
Try out ScrapeGraphAI in your browser:
28+
29+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/VinciGit00/Scrapegraph-ai)
30+
31+
2432
## 📖 Documentation
2533

2634
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
7886

7987
Join our Discord server to discuss with us improvements and give us suggestions!
8088

81-
[![Join Discord Server](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/DujC7HG8)
82-
89+
[![My Skills](https://skillicons.dev/icons?i=discord)](https://discord.gg/DujC7HG8)
90+
91+
8392
You can also follow all the updates on linkedin!
84-
[![Linkedin Badge](https://img.shields.io/badge/-Linkedin-blue?style=flat&logo=Linkedin&logoColor=white)](https://www.linkedin.com/company/scrapegraphai/)
93+
94+
[![My Skills](https://skillicons.dev/icons?i=linkedin)](https://www.linkedin.com/company/scrapegraphai/)
95+
8596

8697
## Contributors
8798
[![Contributors](https://contrib.rocks/image?repo=VinciGit00/Scrapegraph-ai)](https://github.com/VinciGit00/Scrapegraph-ai/graphs/contributors)

scrapegraphai/evaluetor/trulens_evaluetor.py

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import os
2-
from scrapegraphai.graphs import SmartScraperGraph
3-
from openai import OpenAI
1+
"""Module for making the RAG"""
42
from trulens_eval import Feedback, OpenAI as fOpenAI, Tru, Provider, Select, TruBasicApp
3+
from openai import OpenAI
4+
from scrapegraphai.graphs import SmartScraperGraph
5+
56

67
class TrulensEvaluator:
78
"""
@@ -16,20 +17,27 @@ class TrulensEvaluator:
1617
llm_standalone: Standalone function for Trulens evaluation.
1718
"""
1819

19-
def __init__(self):
20+
def __init__(self, key: str):
21+
"""
22+
Initialization of the class
23+
Arguments:
24+
- key (str): openai key
25+
"""
2026
standalone = StandAlone()
2127
f_custom_function = Feedback(standalone.json_complaint).on(
2228
my_text_field=Select.RecordOutput
2329
)
24-
os.environ["OPENAI_API_KEY"] = os.environ["OPENAI_APIKEY"]
25-
client = OpenAI()
30+
client = OpenAI(api_key=key)
2631
tru = Tru()
2732
tru.reset_database()
2833
fopenai = fOpenAI()
2934
f_relevance = Feedback(self.fopenai.relevance).on_input_output()
30-
tru_llm_standalone_recorder = TruBasicApp(self.llm_standalone, app_id="smart_scraper_evaluator", feedbacks=[self.f_relevance, self.f_custom_function])
35+
tru_llm_standalone_recorder = TruBasicApp(self.llm_standalone,
36+
app_id="smart_scraper_evaluator",
37+
feedbacks=[self.f_relevance,
38+
self.f_custom_function])
3139

32-
def evaluate(self, graph_params : list[tuple[str, str, dict]]):
40+
def evaluate(self, graph_params: list[tuple[str, str, dict]]):
3341
"""
3442
Evaluates Trulens using SmartScraperGraph and starts the dashboard.
3543
@@ -59,13 +67,18 @@ def llm_standalone(self, prompt, response):
5967
print(f"Prompt: {prompt}")
6068
return str(response)
6169

62-
"""
63-
Class for standalone Trulens evaluation. Personalise
64-
"""
70+
6571
class StandAlone(Provider):
72+
"""
73+
Class for standalone Trulens evaluation.
74+
"""
75+
6676
def json_complaint(self, my_text_field: str) -> float:
77+
"""
78+
Args:
79+
- my_text_field (str): textfield
80+
"""
6781
if '{' in my_text_field and '}' in my_text_field and ':' in my_text_field:
6882
return 1.0
6983
else:
7084
return 0.0
71-

0 commit comments

Comments
 (0)