Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aichecker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Eggers
aichecker
Commits
3b036e7a
Commit
3b036e7a
authored
6 months ago
by
Jan Eggers
Browse files
Options
Downloads
Patches
Plain Diff
cursor Param in check_handle()
parent
a4799055
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
src/aichecker/check_bsky.py
+1
-62
1 addition, 62 deletions
src/aichecker/check_bsky.py
with
2 additions
and
63 deletions
pyproject.toml
+
1
−
1
View file @
3b036e7a
...
@@ -10,7 +10,7 @@ authors = [
...
@@ -10,7 +10,7 @@ authors = [
maintainers
=
[
maintainers
=
[
{name
=
"Jan Eggers"
,
email
=
"jan.eggers@hr.de"
}
,
{name
=
"Jan Eggers"
,
email
=
"jan.eggers@hr.de"
}
,
]
]
version
=
"0.1.4"
# Neue Versionsnummern für pip-Update
version
=
"0.1.4
.1
"
# Neue Versionsnummern für pip-Update
description
=
"Bluesky-Konten auf KI-Inhalte checken"
description
=
"Bluesky-Konten auf KI-Inhalte checken"
requires-python
=
">
=
3.8
"
requires-python
=
">
=
3.8
"
dependencies
=
[
dependencies
=
[
...
...
This diff is collapsed.
Click to expand it.
src/aichecker/check_bsky.py
+
1
−
62
View file @
3b036e7a
...
@@ -117,12 +117,11 @@ def call_get_profile(handle: str) -> list:
...
@@ -117,12 +117,11 @@ def call_get_profile(handle: str) -> list:
return
None
return
None
return
response
[
''
]
return
response
[
''
]
def
fetch_user_posts
(
handle
:
str
,
limit
:
int
=
100
)
->
list
:
def
fetch_user_posts
(
handle
:
str
,
limit
:
int
=
100
,
cursor
=
None
)
->
list
:
profile
=
call_get_profile
(
handle
)
profile
=
call_get_profile
(
handle
)
did
=
profile
[
'
did
'
]
did
=
profile
[
'
did
'
]
posts
=
[]
posts
=
[]
# Fetch timeline for the user (latest posts first)
# Fetch timeline for the user (latest posts first)
cursor
=
None
while
len
(
posts
)
<
limit
:
while
len
(
posts
)
<
limit
:
feed
=
call_get_author_feed
(
did
,
limit
,
cursor
)
feed
=
call_get_author_feed
(
did
,
limit
,
cursor
)
if
not
feed
[
'
feed
'
]:
if
not
feed
[
'
feed
'
]:
...
@@ -221,63 +220,3 @@ def find_handles(text):
...
@@ -221,63 +220,3 @@ def find_handles(text):
handles
=
[
a
[
'
handle
'
]
for
a
in
actors
[
'
actors
'
]]
handles
=
[
a
[
'
handle
'
]
for
a
in
actors
[
'
actors
'
]]
return
handles
return
handles
if
__name__
==
"
__main__
"
:
# Bluesky-
handle_str
=
input
(
"
Erstes Handle mit diesen Zeichen wählen:
"
)
handle
=
find_handles
(
handle_str
)[
0
]
print
(
handle
)
# Diese Funktion holt die Infos zum Profil 'handle':
# Erwartet einen String, gibt ein dict zurück.
# Beschreibung: https://docs.bsky.app/docs/api/app-bsky-actor-get-profile
# Manchmal existieren Felder wie 'description' nicht.
profile
=
call_get_profile
(
handle
)
author
=
profile
[
'
did
'
]
print
(
author
)
# Diese Funktion holt die Posts.
# 'author' darf irgendwas sein: handle, did... wir nehmen die did
# Gibt ein dict zurück: im Schlüssel 'feed' sind die einzelnen Posts gespeichert,
# im Key 'cursor' gibt es das Datum des frühesten abgefragten Posts zurück (es sei denn,
# es sind weniger Posts als limit, dann ist cursor leer.)
# Beschreibung: https://docs.bsky.app/docs/api/app-bsky-feed-get-author-feed
posts
=
call_get_author_feed
(
author
,
limit
=
limit
)
# In diesem Demo-Programm werden die Posts hier noch nicht ausgewertet.
# Das passiert in der Extra-Funktion check_handle unten.
print
(
posts
[
'
cursor
'
])
# Funktion prüft die letzten ```limit``` Posts (voreingestellt auf 20)
# Erwartet ein Handle oder ein did - wir nehmen DID
# Gibt ein Dataframe zurück; Struktur ist oben in der Funktion beschrieben.
# Wichtigster Punkt: Ergebnis des KI-Checks in den Spalten
# - 'detectora_ai_score': Detectora-Score des Post-Textes (als real)
# - 'aiornot_ai_score':
df
=
check_handle
(
author
,
limit
=
limit
)
n_posts
=
len
(
df
)
print
(
f
'
\n\n
Analyse des Kontos @
{
handle
}
(
{
profile
[
'
displayName
'
]
}
) seit
{
profile
[
'
createdAt
'
]
}
-
{
profile
[
'
followersCount
'
]
}
Follower
'
)
print
(
f
'
{
profile
.
get
(
'
description
'
,
'
---
'
)
}
\n
'
)
print
(
f
'
Anzahl der analysierten Posts:
{
n_posts
}
'
)
print
(
f
"
Durchschnittliche KI-Text-Wahrscheinlichkeit:
{
df
[
'
detectora_ai_score
'
].
mean
()
}
"
)
detectora_posts_df
=
df
[
df
[
'
detectora_ai_score
'
]
>=
d_thresh
]
print
(
f
"
Anzahl von Posts über einer detectora-Schwelle von
{
d_thresh
*
100
:
.
1
f
}
%:
{
len
(
detectora_posts_df
)
}
"
)
image_posts
=
[
post
for
post
in
df
[
'
aiornot_ai_score
'
].
to_list
()
if
post
is
not
None
]
# Liste auspacken, nur die Dicts ohne None-Elemente
image_list
=
[
item
for
sublist
in
image_posts
for
item
in
sublist
]
ai_list
=
[
item
for
item
in
image_list
if
item
[
'
aiornot_score
'
]
!=
'
human
'
]
if
len
(
image_list
)
==
0
:
p_ai
=
0
else
:
p_ai
=
len
(
ai_list
)
/
len
(
image_list
)
*
100
print
(
f
"
Anzahl der Bilder:
{
len
(
image_list
)
}
, verdächtig:
{
len
(
ai_list
)
}
(
{
p_ai
:
.
1
f
}
)%
"
)
# Jetzt die Daten abspeichern
# Fals das Directory nicht existiert, anlegen
if
not
os
.
path
.
exists
(
'
bsky-checks
'
):
os
.
makedirs
(
'
bsky-checks
'
)
# Read existing file if it exists
filename
=
f
'
bsky-checks/
{
handle
}
.csv
'
if
os
.
path
.
exists
(
filename
):
existing_df
=
pd
.
read_csv
(
filename
)
df
=
pd
.
concat
([
existing_df
,
df
]).
drop_duplicates
(
subset
=
[
'
uri
'
]).
reset_index
(
drop
=
True
)
df
.
to_csv
(
f
'
bsky-checks/
{
handle
}
.csv
'
,
index
=
False
)
# Save to CSV for example
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment