File size: 4,360 Bytes
da88846
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from locust import HttpUser, task, between
from gradio_client import Client, handle_file


class GradioAppUser(HttpUser):
    wait_time = between(1, 3)

    def on_start(self):
        self.client = Client("http://sd.demo.polygraf.ai:7890/")

    @task
    def test_generate_text_with_google_search_and_pdf(self):
        generated_text = self.client.predict(
            input_role="Student",
            topic="Low Resource Large Language Models",
            keywords="",
            article_length=350,
            format="Article",
            writing_style="Formal",
            tone="Professional",
            user_category="General Public",
            depth_of_content="Moderate analysis",
            structure="Introduction, Body, Conclusion",
            references="News outlets",
            num_examples="1-2",
            conclusion_type="Call to Action",
            # ai_model="LLaMA 3",
            ai_model="OpenAI GPT 4o Mini",
            google_search_check=False,
            year_from="2000",
            month_from="January",
            day_from="01",
            year_to="2024",
            month_to="August",
            day_to="08",
            domains_to_include=["com", "org", "net", "int", "edu", "gov", "mil"],
            include_sites="",
            exclude_sites="",
            pdf_file_input=None,
            api_name="/generate_and_format",
        )

        self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
        detect_generated = self.client.predict(
            text=generated_text,
            option="Polygraf AI (Advanced Model)",
            api_name="/ai_check",
        )

        humanized_text = self.client.predict(
            text=generated_text,
            model="XL Model",
            temperature=1.2,
            repetition_penalty=1,
            top_k=50,
            length_penalty=1,
            api_name="/humanize",
        )

        self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
        detect_humanized = self.client.predict(
            text=humanized_text,
            option="Polygraf AI (Advanced Model)",
            api_name="/ai_check",
        )

        print(detect_generated)
        print(detect_humanized)

    @task
    def test_generate_text_without_google_search_and_pdf(self):
        generated_text = self.client.predict(
            input_role="Student",
            topic="Low Resource Large Language Models",
            keywords="",
            article_length=400,
            format="Article",
            writing_style="Formal",
            tone="Professional",
            user_category="General Public",
            depth_of_content="Moderate analysis",
            structure="Introduction, Body, Conclusion",
            references="News outlets",
            num_examples="1-2",
            conclusion_type="Call to Action",
            ai_model="LLaMA 3",
            google_search_check=False,
            year_from="2000",
            month_from="January",
            day_from="01",
            year_to="2024",
            month_to="August",
            day_to="08",
            domains_to_include=["com", "org", "net", "int", "edu", "gov", "mil"],
            include_sites="",
            exclude_sites="",
            pdf_file_input=[handle_file("/home/eljan/article_writer/Abstract.pdf")],
            api_name="/generate_and_format",
        )

        self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
        detect_generated = self.client.predict(
            text=generated_text,
            option="Polygraf AI (Advanced Model)",
            api_name="/ai_check",
        )

        humanized_text = self.client.predict(
            text=generated_text,
            model="XL Model",
            temperature=1.2,
            repetition_penalty=1,
            top_k=50,
            length_penalty=1,
            api_name="/humanize",
        )

        self.client.predict(text="Polygraf AI (Advanced Model)", api_name="/highlight_visible_1")
        detect_humanized = self.client.predict(
            text=humanized_text,
            option="Polygraf AI (Advanced Model)",
            api_name="/ai_check",
        )

        print(detect_generated[0]["confidences"])
        print(detect_humanized[0]["confidences"])